Below is the macro I am using and it is working nicely, but I need help with a tweak and can't get it to work.
This macro, enabled in Excel, is part of a chain of macros and will open Word, run the mail merge, save and close Excel. However, there is a macro in Word that I need to run but don't know how to activate it. Is there a code that I am missing that can be added to the end of the macro included?
Sub Mailmerge() Dim wd As Object Dim wdocSource As Object Application.DisplayAlerts = False ' Word constants Const wdFormLetters = 0, wdOpenFormatAuto = 0 Const wdSendToNewDocument = 0, wdDefaultFirstRecord = 1, wdDefaultLastRecord = -16 Dim strWorkbookName As String On Error Resume Next Set wd = GetObject(, "Word.Application") If wd Is Nothing Then Set wd = CreateObject("Word.Application") End If On Error GoTo 0 Set wdocSource = wd.Documents.Open("M:\Access Mgmt\CSAS\Notifications\Notifications TRIAL FBv2.docx") strWorkbookName = ThisWorkbook.Path & "\" & ThisWorkbook.Name wdocSource.Mailmerge.MainDocumentType = wdFormLetters wdocSource.Mailmerge.OpenDataSource _ Name:=strWorkbookName, _ AddToRecentFiles:=False, _ Revert:=False, _ Format:=wdOpenFormatAuto, _ Connection:="Data Source=" & strWorkbookName & ";Mode=Read", _ SQLStatement:="SELECT * FROM `Sheet2$`" With wdocSource.Mailmerge .Destination = wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=False End With wd.Visible = True wdocSource.Close SaveChanges:=False Set wdocSource = Nothing Set wd = Nothing ActiveWorkbook.Saved = True Application.Quit End Sub