I have the following code which opens a word document template and does a mail merge using an access query. Everything works fine but an extra copy of access opens and I want to be able to close it. Any help would be great. Here is the code.
Public Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\mailtest1.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="C:\Reporting Stewardship SYSDB_new.mdb", _
LinkToSource:=True, _
Connection:="QUERY Cover Letter Query", _
SQLStatement:="SELECT * FROM [Cover Letter Query]", _
SubType:=wdMergeSubTypeWord2000
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.Close False
End Function
Public Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\mailtest1.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="C:\Reporting Stewardship SYSDB_new.mdb", _
LinkToSource:=True, _
Connection:="QUERY Cover Letter Query", _
SQLStatement:="SELECT * FROM [Cover Letter Query]", _
SubType:=wdMergeSubTypeWord2000
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.Close False
End Function