Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Designating a particular printer

Status
Not open for further replies.

DeliRick

Programmer
Apr 28, 2002
5
US
I have a VB project that has to print to different printers depending on circumstances. Presently I distinguish between the different printers on my network by using "Set Printer = Printers(0)" (or 1,2,3,etc).

The problem with this is, you need to install the printers in an exact order, and if you change one it screws it all up. Is there a way to designate the printers by their network names? (or some other way?)


 
there must be a better way but you could try this

Code:
Dim oPrinter As Printer
Dim sName As String

sName = "HP LaserJet 5P/5MP PostScript"

For Each oPrinter In Printers
  If oPrinter.DeviceName = sName Then Exit For
Next oPrinter

If oPrinter Is Nothing Then
  MsgBox "Desired printer not found"
Else
  MsgBox oPrinter.DeviceName
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top