vb, ms word, and a printer problem
Posted on 2004-08-29
I have a vb program that opens a word template, changes it, prints it in the background, then closes it.
For some reason, when this is run on a specific machine that uses word 2000, (I don't know if it matters)
it gives an error when I set the printer to a printer name. This works all the time on most machines. It only works once on another, I have to restart to set the printer again.
Here is my code:
Set oWord = CreateObject("Word.Application")
.Documents.add (App.path & "\RptStandard.dot")
.Selection.TypeText "type this"
ActivePrinter = frmMain.clsSetting.getSettings("PrinterPassName") 'this gives the right printer name, I am sure
If err.Number <> 0 Then 'this error happens the second time I run this function
MsgBox "There was an error selecting the printer, the document will not print."
oWord.ActiveDocument.Saved = True
While oWord.BackgroundPrintingStatus > 0
I have another form that pops up a window with all avalible printer names. for some reason, it won't work after I run this function the second time. It seems like for some reason, the printer can't be found.