Se if a printer exists

E

Eric

Does anyone have any code that looks to see if a printer
exists? I want to be able to see if a printer
called "CutePDF Writer" exists, and if not, displays a
message saying that the printer doesn't exists.

Thank you,
Eric
 
D

Dave Lett

Hi Eric,

You can use something like the following:

'''dimension the variables
Dim sPrinter As String
Dim oPrinter As Printer
Dim bExists As Boolean

'''set your variables
sPrinter = "CutePDF Writer"
bExists = False

'''cycle through each printer
For Each oPrinter In Printers
''' if there is a printer with the name you're looking for
If oPrinter.DeviceName = sPrinter Then
'''set bExists to true and exit the loop
bExists = True
Exit For
End If
Next oPrinter

'''if the routine did not change bExists to true
'''then show the msgbox that the printer doesn't exist
If Not bExists Then
MsgBox sPrinter & " does not exist.", vbInformation
End If

HTH,
Dave
 
G

Guest

Is there some reference that I need to check? it doesn't
like Dim oPrinter As Printer.
 

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