![]() |
Error Trap
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 |
Error Trap
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 Kirk P. wrote: 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 -- Dave Peterson |
Error Trap
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 -- bill k ------------------------------------------------------------------------ bill k's Profile: http://www.excelforum.com/member.php...nfo&userid=821 View this thread: http://www.excelforum.com/showthread...hreadid=465632 |
All times are GMT +1. The time now is 08:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com