[AccessD] Wait For Word To Finish Printing

MartyConnelly martyconnelly at shaw.ca
Wed Nov 10 12:47:13 CST 2004


Word normally prints in the background, so you might close Word while it 
is still generating the print file.

There are two ways to avoid this
   1.
 Set the Background parameter of the PrintOut method to False, so that 
the next line of code doesn't execute until the print file has been 
spooled to the printer queue.

ActiveDocument.Printout Background:=False
 
2.
 Check the BackgroundPrintingStatus property of Word's Application 
object, and don't close Word until the value reaches zero. To make sure 
that you aren't unnecessarily delaying the printing process by eating 
cycles within the same thread, use a timer that triggers a check every 
few seconds.

Generally, option #1 is safer, because Word can sometimes get a bit 
confused if asked to background print too many documents at once.


ACTEBS wrote:

>Guys,
>
>I have a function that prints out numerous Word documents on the fly which I loop through. The problem is the print job hasn't finished and a dialogue box pops up suggesting that "If you close word now the document print job will be cancelled"
>
>The code is as follows:
>
>    With m_objWord
>        .ActiveDocument.SaveAs strWrdPath
>        
>        If gBoolPrintOrNot = True Then
>            .ActiveDocument.PrintOut
>            DoEvents
>        End If
>        
>        .ActiveDocument.Close
>    End With
>    
>    m_objWord.Quit
>    Set m_objDoc = Nothing
>    Set m_objWord = Nothing
>
>It works well other than I have to close after I am finished as I don't want to leave variables in memory. Is there any way to wait until word has finished it's job?
>
>I have tried Dev's "ShellWait" function, but that is more geared to batch files rather than a windows app, and it's not the word document that is the process, it's word that is executing the process....
>
>Any guidance much appreciated...
>
>Vlad
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list