Link to home
Start Free TrialLog in
Avatar of TheNugget
TheNugget

asked on

Qustion 2: Word 8.0 object model

Assuming the objects have been declared and created, in the following code:

objDoc.SaveAs "test"
objDoc.PrintOut
objDoc.Close
objWordApp.Quit

how would I make it so that I the line:

objWordApp.Quit

was not called until "test.doc" had finished printing?

Thanks a lot,

TheNugget
Avatar of ivanc
ivanc

TheNugget

Maybe U should check for the printing flag.  I am not sure how but there should be an API to help U ensure that the printout is completely sent to the printer.

Just a suggestion
Ivanc

The PrintOut method on the Document object has a parameter BackGround. (Actually the first parameter)

This is a boolean.  When set to true the code keeps running and printing is done in the background.

So, I think setting it to false will halt your code until it's printed.  Continuing then is no problem.

I won't post it as an answer, since I did not check it.  Just inform me if my thought was correct.

Type DoEvents before the objWordApp.Quit

The DoEvents function yields to the operating system so it can process other operations.  It essentially allows the operating system to process pending events.




Avatar of TheNugget

ASKER

The DoEvents method did not work. however, setting the background print flag to False did work (suggested by vindevogel). Thanks for that.
ASKER CERTIFIED SOLUTION
Avatar of vindevogel
vindevogel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial