Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word quits too fast...

Status
Not open for further replies.

ztm

IS-IT--Management
Jul 19, 2001
34
US
Hey all.
I'm creating an access form that prints a Word document. It works great if I step (F8) through the code, but when I run it in real-time, I get a message from Word that says "...quitting Word will cancel print jobs." Obviously the code is running too quick for the document to get to the printer, but how do I make it wait until that happens?

Private Sub cmdWord_Click()

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

wordApp.Documents.Open FileName:="c:\mydoc.doc"
wordApp.ActiveDocument.PrintOut
wordApp.ActiveDocument.Close
wordApp.Quit

Set wordApp = Nothing
End Sub
 
Well there may be a better method of doing this, but seeing as I'm not too familiar with all VB commands, I would fix that problem by holding the program for a few seconds :

Application.Wait Now + TimeValue("HH:MM:SS")

Hope that helps!

 
Thanks John,
It seems so obvious...now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top