jrussellpowell
New Member
- Joined
- Dec 15, 2009
- Messages
- 1
Ok, I have been trying to sort this out on my own all day with no success, so maybe someone here can help.
I have a workbook setup with multiple sheets. Each section has an export button created for it which links to a user form. The user form gives 2 options: export to PDF & export as a Microsoft Document Image. I am having the same issue with both, so I will explain the PDF.
The PDF "export" is being done with PDFCreator which works as a printer like Primo PDF or Cute PDF. I can write the macro and get it working fine for myself, but this workbook will also be used by other people. They have the same PDF program, but it is not working on the same printer port. I have tried to use the get error command to get around this, with no luck.
Essentially what I need is the code to do is: try to print on "PDFCreator on Ne01:", if it succeeds, then end the sub, if it fails, try to print to "PDFCreator on Ne02:", if it fails....etc. Basically, I want it to keep trying on each port in a range until it finds the one that works.
Can anyone help? Here is the lousy code I have put together so far:
Private Sub CommandButton3_Click()
On Error GoTo ERR_Handler
AIBUExportType.Hide
Sheets(Array("AIB (1)", "AIB (2)", "AIB (3)")).Select
Sheets("AIB (1)").Activate
Application.ActivePrinter = "PDFCreator on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne00:", Collate:=True
Sheets("AIB (1)").Select
Exit Sub
ERR_Handler:
On Error GoTo ERR_Handler2
Application.ActivePrinter = "PDFCreator on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne00:", Collate:=True
Sheets("AIB (1)").Select
Exit Sub
ERR_Handler2:
On Error GoTo ERR_Handler3
Application.ActivePrinter = "PDFCreator on Ne02:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne02:", Collate:=True
Sheets("AIB (1)").Select
Exit Sub
ERR_Handler3:
On Error GoTo ERR_Handler4
Application.ActivePrinter = "PDFCreator on Ne03:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne03:", Collate:=True
Sheets("AIB (1)").Select
Exit Sub
ERR_Handler4:
On Error GoTo 0
Application.ActivePrinter = "PDFCreator on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne04:", Collate:=True
Sheets("AIB (1)").Select
End Sub
I have a workbook setup with multiple sheets. Each section has an export button created for it which links to a user form. The user form gives 2 options: export to PDF & export as a Microsoft Document Image. I am having the same issue with both, so I will explain the PDF.
The PDF "export" is being done with PDFCreator which works as a printer like Primo PDF or Cute PDF. I can write the macro and get it working fine for myself, but this workbook will also be used by other people. They have the same PDF program, but it is not working on the same printer port. I have tried to use the get error command to get around this, with no luck.
Essentially what I need is the code to do is: try to print on "PDFCreator on Ne01:", if it succeeds, then end the sub, if it fails, try to print to "PDFCreator on Ne02:", if it fails....etc. Basically, I want it to keep trying on each port in a range until it finds the one that works.
Can anyone help? Here is the lousy code I have put together so far:
Private Sub CommandButton3_Click()
On Error GoTo ERR_Handler
AIBUExportType.Hide
Sheets(Array("AIB (1)", "AIB (2)", "AIB (3)")).Select
Sheets("AIB (1)").Activate
Application.ActivePrinter = "PDFCreator on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne00:", Collate:=True
Sheets("AIB (1)").Select
Exit Sub
ERR_Handler:
On Error GoTo ERR_Handler2
Application.ActivePrinter = "PDFCreator on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne00:", Collate:=True
Sheets("AIB (1)").Select
Exit Sub
ERR_Handler2:
On Error GoTo ERR_Handler3
Application.ActivePrinter = "PDFCreator on Ne02:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne02:", Collate:=True
Sheets("AIB (1)").Select
Exit Sub
ERR_Handler3:
On Error GoTo ERR_Handler4
Application.ActivePrinter = "PDFCreator on Ne03:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne03:", Collate:=True
Sheets("AIB (1)").Select
Exit Sub
ERR_Handler4:
On Error GoTo 0
Application.ActivePrinter = "PDFCreator on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator on Ne04:", Collate:=True
Sheets("AIB (1)").Select
End Sub