Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-07-2019, 01:16 AM
andywal6 andywal6 is offline Email macro saving the wrong document Windows XP Email macro saving the wrong document Office 2000
Novice
Email macro saving the wrong document
 
Join Date: Jun 2010
Posts: 2
andywal6 is on a distinguished road
Default 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
Many thanks in advance for your help,

Andy
Reply With Quote
  #2  
Old 08-13-2019, 09:00 PM
eduzs eduzs is offline Email macro saving the wrong document Windows 10 Email macro saving the wrong document Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

You can try: (backup before test)
Code:
ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) & " " & vsn & ".doc", FileFormat:=wdFormatXMLDocument
__________________
Backup your original file before doing any modification.
Reply With Quote
Reply



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
Email macro saving the wrong document 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
Email macro saving the wrong document Macro operates on wrong document window marceepoo Word VBA 1 12-20-2012 03:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:15 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft