PDA

View Full Version : Wait while word is printing



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

CreganTur
04-27-2010, 11:52 AM
I have an application that does the same thing- printing mail merge docs based on access records. The difference is that I don't have any code to keep the database from doing anything while it's printing. The user's printing screen just has very limited functionality and they've been trained not to do anything else with the database until printing is complete.

jk0124
04-27-2010, 12:09 PM
Randy,
Thanks for the quick reply.. My application goes on to do other things after word finishes creating the PDF. It runs other queries and clears out tables which the word document looks for and then archives those records.. So I have to wait for the mailmerge to finish or else the records that it's reading from the tables would get cleared and moved.