View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mike Molyneaux[_2_] Mike Molyneaux[_2_] is offline
external usenet poster
 
Posts: 3
Default Excel code to Wait until Word finishes printing before closing

I'm using Excel 2000 & windows nt 4, sp6.

I'm using Excel to extract label info to a 'prn' file,
then opening a Word doc & merging 'prn' info, then
printing the merged document.

Works great - except that when I attempt to close the word
object, I get a message that Word is printing & closing
will stop the printing. Don't want that to happen, but I
also want to close Word from within Excel.

My question is: Is there a way to execute a loop to
determine when the print job has finished? Where do I put
the loop? Or this a needless worry?

Thanks - mike

Code:

Dim wordApp As Object
Set wordApp = CreateObject("Word.Application")

With wordApp
.Documents.Open Filename:="1.doc", _

(formatting code)

.Application.PrintOut Filename:="1.doc", _

.activeDocument.Close

End With

wordApp.Quit