We help IT Professionals succeed at work.

How to list Network Printers?

virgils
virgils asked
on
I some of my network printers listed in a combobox..

thanks!
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Hi

'Add ComboBox1 at your Form
Private Sub Form_Load()
   Dim WshNetwork As Object
   Dim oPrinters As Object
   Dim sPrn As String
   Set WshNetwork = CreateObject("WScript.Network")
   Set oPrinters = WshNetwork.EnumPrinterConnections
   WScript.Echo "Network printer mappings:"
   For i = 0 to oPrinters.Count - 1 Step 2
      sPrn = "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1)
      Combo1.AddItem sPrn
   Next
   Set oPrinters = Nothing
   Set WshNetwork = Nothing
End Sub

Cheers

Author

Commented:
thanks, but how do i get the wscript.network from?
Here is a website with an example: http://www.mvps.org/vbnet/

Look under Code Library, then System, then Enumerating Local and Network Printers.

Thanks!

Joe
CERTIFIED EXPERT
Author of the Year 2009

Commented:
Hi virgils,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Ark's comment(s) as an answer.

virgils, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
CS Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.