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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to list all Printers on a network

Status
Not open for further replies.

excelhelp

Technical User
Dec 4, 2006
5
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top