jk0124
04-27-2010, 11:46 AM
I have a Word document which creates a final document based on the records from access 2003 using mailmerge. I'm having problems with the printing to PDF. After debugging, I saw that because of the following code, the printing is occurring SLOWLY (~2pg/min). Some documents can be 300 pages long. I'm using this code to just tell the VBA code to wait until Word is finished printing the document to a PDF. Is there a better way to do this?
'-- Execute the mail merge
objWordDoc.MailMerge.Execute Pause:=False
'THIS IS WHERE IT TAKES A LONG TIME.
If objWordApp.Options.BackgroundOpen = True Then
'While jobs in queue
While objWordApp.BackgroundPrintingStatus
DoEvents
Wend
While objWordApp.BackgroundSavingStatus
DoEvents
Wend
End If
'-- Execute the mail merge
objWordDoc.MailMerge.Execute Pause:=False
'THIS IS WHERE IT TAKES A LONG TIME.
If objWordApp.Options.BackgroundOpen = True Then
'While jobs in queue
While objWordApp.BackgroundPrintingStatus
DoEvents
Wend
While objWordApp.BackgroundSavingStatus
DoEvents
Wend
End If