I have the below code in my attempt to run a mail merge. I keep getting the run-time error:
"Automation error
"Unspecified error"
on the highlighted line of code. Help/direction is much appreciated!
Code:
Function funMergeIt()
Dim strPathFile As String, strTable As String
Dim objDesktop As Object
Dim ObjWord As Word.Document
Set objDesktop = CreateObject("WScript.Shell")
strPathFile = objDesktop.SpecialFolders("Desktop") & "\ContactListEnvelop.docx"
Set ObjWord = GetObject(strPathFile, "Word.Document")
ObjWord.Application.Visible = True
ObjWord.MailMerge.OpenDataSource _
Name:="C:\Data\DMPhoneList_Fe_NEW.accdb", _
LinkToSource:=True, Connection:="QUERY qryDMMailMerge", _
SQLStatement:="SELECT * FROM [qryDMMailMerge]"
ObjWord.MailMerge.Execute
End Function