I am using code in Access to run a merge in Word. I'll call the database containing the function (MergeWord) that runs the merge Database1. The table used in the merge is in a different database. I'll call the database that contains the table Database2. When the merge is run, another instance of Access is automatically opened with Database2 open. How do I close the second instance of Access (Database2)?
Here's my code so far:
Here's my code so far:
Code:
Function MergeWord()
Dim ObjWord As Word.Document
Set ObjWord = GetObject("H:\SHARED\FORMS\Test.doc", "Word.document")
ObjWord.Application.Visible = True
ObjWord.MailMerge.OpenDataSource NAME:="H:\Access\Database2.mdb", Linktosource:=True, Connection:="TABLE NewFileExport"
ObjWord.MailMerge.Destination = wdSendToNewDocument
ObjWord.MailMerge.Execute
ObjWord.Application.NormalTemplate.Saved = True
ObjWord.Activate
ObjWord.Close False
Set ObjWord = Nothing
Exit Function
End Function