Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

Se if a printer exists

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric - 18 Feb 2005 16:49 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.