strong textI have a simple word form that I want to print. I pass the printer name to a sub routine (myprint) in the variable oprinter. The variable printcomplete will pass back the name of the printer that was successful in printing the data.
This logic works when I am in debug mode but appears to bypass the print commands when not in debug. I have tried adding delays, I have added a MSGBOX after the print statement (prior to printcomplete = oprinter > Exit Sub). The MSGBOX does display - so it should have executed the print statement. I do not get the msgbox under myprinterr.
Any idea why it won't print out of debug mode?
Here is my code:
'Print MS Word Form to one of three networked printers
Sub MyPrint(oprinter, printcomplete)
Dim sPrinter As String
On Error GoTo myprinterr
Sleep (5000)
With Dialogs(wdDialogFilePrintSetup)
sPrinter = .Printer
.Printer = oprinter
.DoNotSetAsSysDefault = True
.Execute
Sleep (5000)
Application.PrintOut FileName:=""
.Printer = sPrinter
.Execute
End With
Sleep (5000)
MSGBOX "Did it print? "
printcomplete = oprinter
Exit Sub
myprinterr:
MsgBox "oops printer error on: " & oprinter
End Sub