Error Trap

K

Kirk P.

I'm fairly new at programming - I've successfully written this code, but I'd
like to set an Error Trap in the event the ActivePrinter cannot be found.
Can someone provide the code I would need to accomplish this? Thank you!

Sheets(Array("Cover", "Consol PL", "AMER PL", "EMEA PL", "INDO PL", "ASIA
PL", _
"ACTIVE PL", "gcs pl", "wrls pl", "wline pl", "aps pl", "hmwx pl", "other
adc pl", _
"Consol BS", "Amer BS", "EMEA BS", "Indo-pac BS", "Asia BS", "Other
BS")).Select
Application.ActivePrinter = "Acrobat Distiller on Ne01:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Acrobat Distiller on Ne01:", Collate:=True
Sheets("Input").Select
 
D

Dave Peterson

Maybe something like:

Option Explicit
Sub testme()
Dim OldPrinter As String

OldPrinter = Application.ActivePrinter
On Error Resume Next
Application.ActivePrinter = "Acrobat Distiller on Ne01:"
If Err.Number <> 0 Then
MsgBox "Printer not available"
Else
'do the printing
'and change the printer back
Application.ActivePrinter = OldPrinter
End If
End Sub
 
B

bill k

Not sure whether this could also be the problem at your
place.............but

I have been working with this solution for a while now.
We had the problem of the network assigning different numbers to the
network printers using Ne01, Ne02, Ne03 or Ne04.
This macro will search the possibilities and always find the right
one.
It will then execute the print job and go back to the default printer



Sub selectprntrandprintlbl()
Dim oldpname As String
Dim temppname As String
oldpname = Application.ActivePrinter
For j = 0 To 9
On Error Resume Next
temppname = "Acrobat Distiller on Ne0" & j & ":"
Application.ActivePrinter = temppname
If Application.ActivePrinter = temppname Then
Exit For
End If
Next j
Application.ActivePrinter = "temppname"
prntlbl 'prntlbl is the name of a macro
Application.ActivePrinter = oldpname

End Sub

Hope that helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top