View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 292
Default Verifying Printer with Excel VBA

Hi Craig

Try it and see if it errs, if so, reset to previous, if not, ok. Like this:

Sub test()
If PrinterOK("HPPhpoto on LPT1:") Then
MsgBox "OK"
Else
MsgBox "Not cool"
End If
End Sub

Function PrinterOK(sPrinterName As String) As Boolean
Dim sCurrPrinter As String
sCurrPrinter = Application.ActivePrinter
On Error Resume Next
Application.ActivePrinter = sPrinterName
DoEvents
If Err.Number < 0 Then
Application.ActivePrinter = sCurrPrinter
DoEvents
PrinterOK = False
Else
PrinterOK = True
End If
End Function

HTH. Best wishes Harald

"Craig" skrev i melding
news:gYaUe.450089$5V4.294592@pd7tw3no...
Hi...
I know that I can change the printer with:
Application.Activeprinter="HPPhpoto on LPT1:"

Is there any way of checking the existance of the printer before using the
Activeprinter change?
I just want to be sure the printer exist before I create an error if it
doesn't... because I'm dealing with over 100 printers!
Craig