Mailmerge to Word - How to suppress message...

L

Linda

I have written the following routine that performs a
mailmerge to word. This works fine execpt that my users
are always getting the following error message:

"Word is currently printing. Quitting Word will Cancel all
Print Jobs. Do you want to Quit Word?".

Is there any way to supress this message? - TIA.

Set objWord = CreateObject("Word.Application")

DoCmd.Hourglass True
Echo True, "Printing Memorandum...."
objWord.Documents.Open
("C:\temp\outstandingbill2.doc")
objWord.Application.Visible = False
XOriginalPrinter = objWord.Application.ActivePrinter
objWord.Application.ActivePrinter = "\\SERVER01
\PRINT01"
objWord.ActiveDocument.PrintOut
objWord.Application.ActivePrinter = XOriginalPrinter
objWord.ActiveDocument.Saved = True
objWord.Quit
Set objWord = Nothing
DoCmd.Hourglass False
 
D

Dave Jones

The problem arises because you are trying to close the
instance of word before printing has finished (You have to
remember that there may be other jobs in the print queue
before the one from your users). I don't think you can
surpress the message as such but I use the following:
While objWord.BackgroundPrintingStatus <> 0
DoEvents
Wend
This needs to be inserted before the objWord.Quit
statement.
What happens is that until printing has finished, word
remains open so the error message is not displayed. The
downside is that the code does not continue until
BackgroundPrintingStatus becomes zero (i.e. the print job
has finished).
I have used this sucessfully with some very large print
jobs where the user is printing upto seventy individual
letters in one go.

hth

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top