Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Verifying Printer with Excel VBA

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Verifying Printer with Excel VBA

Craig,
Can't you just trap the error ?

NickHK

"Craig" wrote in message
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Verifying Printer with Excel VBA

Thanks Harald... worked like a charm!
Craig


"Harald Staff" wrote in message
...
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Look up a value from a row after verifying two other values Paul W Excel Worksheet Functions 11 September 1st 08 08:59 PM
members on my network printer not able to print to default printer smeheut Excel Discussion (Misc queries) 0 June 18th 07 06:42 PM
Printer Multiple Worksheets with a particular Printer Setting PP[_2_] Excel Worksheet Functions 0 March 14th 07 02:02 PM
Verifying value of a cell El Criollo Excel Discussion (Misc queries) 7 December 12th 06 10:21 AM
Verifying Dates gilbert Excel Worksheet Functions 1 September 8th 05 03:22 AM


All times are GMT +1. The time now is 12:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"