I am using the following VB code to open a mailmerged document and print it. This worked fine until we had to allow more users access to the database. We then thought it would be best to hide the database window so that nobody could mess things up. However, due to this, the mail merge code doesn't work?
Any ideas?
Thanks in advance
Lee
Dim objWord As Word.Document
Set objWord = GetObject("J:\Admin\ISES\P_CapitaBookingForm.dot", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
objWord.MailMerge.OpenDataSource Name:="J:\Admin\ISES\ISES.mdb", _
LinkToSource:=True, _
Connection:="Query qryCourseBookingMailMerge"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
'The following line must follow the Execute statement because the PrintBackground property is available only when a document window is active. Without this line of code, the function will end before Word can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
Any ideas?
Thanks in advance
Lee
Dim objWord As Word.Document
Set objWord = GetObject("J:\Admin\ISES\P_CapitaBookingForm.dot", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
objWord.MailMerge.OpenDataSource Name:="J:\Admin\ISES\ISES.mdb", _
LinkToSource:=True, _
Connection:="Query qryCourseBookingMailMerge"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
'The following line must follow the Execute statement because the PrintBackground property is available only when a document window is active. Without this line of code, the function will end before Word can print the merged document.
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut