#1
|
|||
|
|||
Email macro saving the wrong document
Hi Guys
I'm using the code below to Merge a word document then send by email and save it to a specified location. All seems to work well except that it is saving the template and not the merged document. The E.mail comes out brilliantly. Why is it saving the template. Code:
Sub SendMergedDocByEmail() '*** Macro to Automate Merge and Send by Email *** Dim fldrname, vsn, defaultpath, strSend vsn = Format(Now, "dd-mm-yy") strSend = InputBox("Enter a Subject line or Click [OK] to accept the Default", "Enter a Subject line", "Your Documents as promised") If strSend = "" Then Application.Quit SaveChanges:=wdDoNotSaveChanges With ActiveDocument.MailMerge .Destination = wdSendToEmail .MailAddressFieldName = "CustEmail" .MailSubject = strSend .SuppressBlankLines = True .MailAsAttachment = False .MailFormat = wdMailFormatHTML With .DataSource .ActiveRecord = wdFirstRecord defaultpath = .DataFields("DefaultFolder").Value fldrname = .DataFields("FolderNo").Value .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=False End With ActiveDocument.SaveAs FileName:=defaultpath & "\" & fldrname & "\" & _ ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) & " " & vsn & ".doc" Application.Quit SaveChanges:=wdDoNotSaveChanges End Sub Andy |
#2
|
|||
|
|||
You can try: (backup before test)
Code:
ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) & " " & vsn & ".doc", FileFormat:=wdFormatXMLDocument
__________________
Backup your original file before doing any modification. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook 2010: Saving attachments opens up wrong windows folder to save in | jeroen | Outlook | 0 | 09-29-2015 01:51 AM |
Wrong email opening | krosa290 | Outlook | 0 | 01-23-2015 11:30 AM |
Word 2010 - Saving Wrong Version | WordMaus | Word | 2 | 12-24-2013 08:27 AM |
Macro to send document in email | AnneN | Word VBA | 1 | 02-05-2013 08:08 PM |
Macro operates on wrong document window | marceepoo | Word VBA | 1 | 12-20-2012 03:12 PM |