Macro to list all Printers on a network

Excel2006

Active Member
Joined
Dec 19, 2006
Messages
455
Hi

Someone wrote the macro below to show all printers that a user is connected to. I modified it so that it shows the info in an excel sheet.
IT shows the printer name.
What would I need to change in the Macro to list all Printers on a particular Windows network, whether I am connected to them or not?


Sub PrintersOnNetwork()

'Check which Printers u r connected to, msgbox

Set WshNetwork = CreateObject("WScript.Network")
Set objPrinters = WshNetwork.EnumPrinterConnections
PrinterStr = "Printers:" & Chr(13)
For i = 0 To objPrinters.Count - 1 Step 2
PrinterStr = PrinterStr & "Printer " & objPrinters.Item(i) & " = " & objPrinters.Item(i + 1) & Chr(13)

Sheets("PrinterList").Activate
Cells(i + 1, 1).Value = "Printer " & objPrinters.Item(i) & " = " & objPrinters.Item(i + 1) & Chr(13)

Next

Columns(1).AutoFit


End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Id really like to know the answer to this also :biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,613
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top