My Assistant
![]()
Custom Search
|
![]() ![]() |
![]() |
![]() Post#1 | |
Posts: 131 Joined: 11-January 08 ![]() | Hey Guys I've cobbled together the Macro below to Merge word doc and send out as html email. The email address is one of the merge fields called 'CustEmail' but am having trouble with the code reference. The code after '.MailAddressFieldName' It's just a little mixed up. Can anyone help me to sort it out. Many thanks for viewing. CODE Sub SendMergedDocByEmail() With ActiveDocument.MailMerge .Destination = wdSendToEmail .MailAddressFieldName = ActiveDocument.MailMerge.DataSource.DataFields("CustEmail").Value '**This bit!** .MailSubject = "Your Documents as promised" .SuppressBlankLines = True .MailAsAttachment = False .MailFormat = wdMailFormatHTML With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=False End With End Sub |
![]() Post#2 | |
Posts: 300 Joined: 25-January 16 ![]() | Is this code in Access module? Not seeing data source opened. Following appears to be a good example https://rtmccormick.com/2015/11/23/automati...VBA-and-access/ -------------------- To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window. |
![]() Post#3 | |
Posts: 131 Joined: 11-January 08 ![]() | HI June7 It will be a Macro in Word Normal template, called by an icon in the QATB. Andy |
![]() Post#4 | |
Posts: 300 Joined: 25-January 16 ![]() | The only example I can find simply references the field name: .MailAddressFieldName = "CustEmail" -------------------- To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window. |
![]() Post#5 | |
Posts: 131 Joined: 11-January 08 ![]() | Many thanks June7 All done now and the final Macro is below. CODE Sub SendMergedDocByEmail() '*** Macro to Automate Merge and Send by Email *** '*** (CustEmail) on line 4 is the name of the merge field in your document *** Dim strSend With ActiveDocument.MailMerge .Destination = wdSendToEmail .MailAddressFieldName = "CustEmail" 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 .MailSubject = strSend .SuppressBlankLines = True .MailAsAttachment = False .MailFormat = wdMailFormatHTML With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=False End With Application.Quit SaveChanges:=wdDoNotSaveChanges End Sub Regards Andy......... |
![]()
Custom Search
|
![]() | Search Top Lo-Fi | 22nd February 2019 - 10:31 AM |