Running Word Mail Merge from Access opens 2 emtpy instances of Word
Posted on 2016-10-28
Hello - I'm having a problem running Word mail merge from Access, using the code below. This routine is kicked off from a command button; when the users click this button the 1st time, 2 empty instances of Word appear, with no template doc or mail merge result doc in either one. Then they click the button a second time, and a 3rd instance of Word comes up, with the mail merge result doc.
What's really driving me crazy is that *I* am not having the problem when I run on my pc, but all the users are.
I will admit to not knowing how to reference the original application instance, as opposed to the mail merge result instance. So when I close the original instance, and make the result instance visible, I might not be doing that in the best way. But why would it have the problem on the 1st execution, and not the 2nd?
Everybody is running Office 2003 on Windows 7; some (me included) have 4GB RAM, most only have 2GB, but even the 4GB users are having this problem.
JUST NOW >>> one user just told me that he does not have the 2 instances problem when he closes Outlook before running the mail merge. This makes sense because they all have their Outlook message editor set to use Word, and I don't. If this is the problem, is there a work-around?
'-- code before here strings together the Word mail merge templates folder path with the template file name, resulting in "strDocFullLoc"
Application.Echo True, "Starting Word..."
Set objWordApp = CreateObject("Word.Application")
Application.Echo True, "Opening mail merge template..."
Set objWordDoc = GetObject(strDocFullLoc, "Word.Document")
Application.Echo True, "Starting Mail Merge..."
'-- execute the merge
objWordDoc.MailMerge.Destination = wdSendToNewDocument
'-- close the merge template (leaves the merge result doc open), show Word
Application.Echo True, "Closing mail merge template..."
objWordApp.Visible = True
MsgBox "Mail Merge Complete", vbOKOnly, strMBTitle