I have a report set up that has a simple button on the home page of the report that will print the report to PDF. All of the computers at my work use PrimoPDF on Ne00: and the code works great. However, our Houston shop computers use AdobePDF on TS002: So I need a way that it will check for one printer and if that errors out, it will go to the next printer, and then if that also errors out, I want it to go to a message box about a printing error. Here is the code I have right now that doesn't seem to work. It errors out to "1:" but then if I force an error (ie changing to PrimoPD on Ne00) then it gives a run-time error instead of my message box.
Thanks in advance.
Thanks in advance.
Code:
Private Sub CommandButton1_Click()
Select Case MsgBox("Are you sure you want to print to PDF?", vbYesNo, "Confirm printing")
Case vbYes
Call PrintSubCode
Case vbNo
End
End Select
End Sub
Sub PrintSubCode()
Dim strCurrentPrinter As String
strCurrentPrinter = Application.ActivePrinter
On Error GoTo 1
Application.ActivePrinter = "AdobePDF on TS002:"
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
Application.ActivePrinter = strCurrentPrinter
Exit Sub
1: On Error GoTo Error
Application.ActivePrinter = "PrimoPDF on Ne00:"
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
Application.ActivePrinter = strCurrentPrinter
Exit Sub
Error: MsgBox "An error has prevented this report from printing.", vbOKOnly, "Printing Error"
End Sub