Print and Exit Macro

  • Thread starter Thread starter JCheah
  • Start date Start date
J

JCheah

Hi ppl!

I am using Word 97 (i know it's ancient). I am trying to create
macro that prints the current document, then exits word. My curren
macro looks like this:

.... lots of formatting.....
ActiveDocument.PrintOut
Application.Quit (False)
end sub

with this code nothing prints out.

if i remove the "application.quit(false)".. my document prints fine.

i am guessing that when i exit word it is retracting the call to prin
because the printer icon comes up in the system tray but it goes awa
pretty fast and nothing prints and the message at the bottom of th
window says "word is preparing to background print the document"

do i need a pause between the print and the quit?

thanks for any suggestions
 
Yes, I think the print command is sent, but of course the printing takes
a while, but in the meantime you've sent the command to quit word, so
everything stops.

A possible alternative might be, instead of quitting Word, to close the
document and minimize Word. This at least gets the document closed and
Word out of the way, and it doesn't interfere in the printing.

ActiveDocument.PrintOut

ActiveDocument.Save
ActiveWindow.Close
Application.Visible = False
Application.WindowState = wdWindowStateMinimize

Larry
 
Use the following to prevent the next line of code from executing until the
printing is complete:

ActiveDocument.PrintOut Background:=False


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
Back
Top