checking printer status and pausing
Posted on 2002-03-12
I am trying to print a lot of Word 2000 documents using the folling code:
'keep looping until all printed
InvoiceObj.Selection.GoTo what:=-1, Name:="ContactTitleLastName"'InvoiceObj.Selection.Font.Bold = wdToggle
InvoiceObj.Selection.InsertAfter " " & sContactTitle & " " & sContactLastName
InvoiceObj.Selection.Font.Color = 0
InvoiceObj.Application.Visible = False
InvoiceObj.ChangeFileOpenDirectory App.Path & "\"
InvoiceObj.ActiveDocument.SaveAs FileName:="LetterTo" & sContactCompany & sContactTitle & sContactFirstName & sContactLastName & ".doc"
Set InvoiceObj = Nothing
Basically, I am opening a Word document, inserting some data, saving the doc as a different name, and then printing it.
2 problems occur. I get an error saying that a previous copy has been open, even though I closed it. Second, the printer does not like it when too many jobs come at once.
So, I would like to be able to wait until one print job is done before sending the next. AND I would like to be able to open the document and close it without any problems. The code within the ... gets repeated in a loop. Other code checks to make sure the file is NOT-read-only. It also, opens rather than creates the document.
Any ideas how to solve these two problems. Successful Working Sample code will get you the points.