I am trying to save my mail merge document to a specific folder. I have the code to automatically fill out my word mail merge document and have the Finish Merge new window (Usually labeled as Letters1 Word Document) pop up with the merge ready to print. I want to save that new window automatically. Here is what I have but it is not working.
Sub Mailmerge()
Dim wd As Object
Dim wdocSource As Object
Dim wDoc As String
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
Application.Dialogs(xlDialogSaveAs).Show
'Create File Name String
strWorkbookName = ThisWorkbook.Path & "\" & ThisWorkbook.Name
wDoc = ThisWorkbook.Path & "\Master Print Tags.docx"
Set wdocSource = wd.Documents.Open(wDoc)
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 `TAG List$`"
With wdocSource.Mailmerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
ActiveWorkbook.Saved = True
Application.WindowState = xlMinimized
wd.Visible = True
wdocSource.Close SaveChanges:=False
wd.WindowState = wdWindowStateMinimize
wd.WindowState = wdWindowStateMaximize
ActiveDocument.SaveAs Filename:="C:\Users\Desktop\Legal Tags\Final Print Tags.doc", FileFormat:= _
wdFormatDocument
'Set wdocSource = Nothing
'Set wd = Nothing
End Sub
Thanks
Bookmarks