stall between printing and closing
I have an open document that I want printed and then closed. here is the code
VB Code:
ActiveDocument.PrintOut
Kill "temp.doc"
ActiveDocument.Close False
Application.Quit False
I want it to print the active document, delete the temp.doc file, close the document and then close word.The problem is it all happens too fast that it doesn't print the active document.
Any ideas on how to do this?
Re: stall between printing and closing
try inserting a after the printout line.
Re: stall between printing and closing
2 things. First, don't try to kill the document until after it has been closed. Second, you can use the BackgroundPrintingStatus property to see if Word has uncompleted print jobs:
VB Code:
ActiveDocument.PrintOut
Do Until Application.BackgroundPrintingStatus = 0
DoEvents
Loop
ActiveDocument.Close False
Application.Quit False
Kill "temp.doc"
Re: stall between printing and closing
This last suggestion works, but there is a long (minute or more) delay before printing...
Unless I put a break point at the DoEvents, then it seems to trigger an immediate print.
Any suggestions how to trigger it immediately in code?