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
Dave Lett - 18 Feb 2005 17:18 GMT
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
> Does anyone have any code that looks to see if a printer
> exists? I want to be able to see if a printer
[quoted text clipped - 3 lines]
> Thank you,
> Eric
anonymous@discussions.microsoft.com - 18 Feb 2005 17:55 GMT
Is there some reference that I need to check? it doesn't
like Dim oPrinter As Printer.
Jonathan West - 19 Feb 2005 18:24 GMT
Hi Eric,
Take a look at this article.
Getting names of available printers
http://www.word.mvps.org/FAQs/MacrosVBA/AvailablePrinters.htm
Once you have the list of printers, you can see if the one you want is in
the list

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
> Does anyone have any code that looks to see if a printer
> exists? I want to be able to see if a printer
[quoted text clipped - 3 lines]
> Thank you,
> Eric