View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
RobC[_3_] RobC[_3_] is offline
external usenet poster
 
Posts: 11
Default Listing Printers in Excel

Steve,

This is what I was looking for but hard to find info on.

Are there anyother properties other than Name and Default? i.e., Port?

The link on the next response was also good but very complex.

Thanks... Rob



"Steve Yandl" wrote in
:

Rob,

The Word MVPs have a discussion on using the Windows API he
http://word.mvps.org/FAQs/MacrosVBA/...lePrinters.htm

If you knew the users were all using WindowsXP you could use something
like this:

Sub PrinterList()
Dim R As Integer

R = 2
strComputer = "."

Cells(1, 1).Value = "Printer Name"
Cells(1, 2).Value = "Default"

Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer")

For Each objPrinter In colPrinters
Cells(R, 1).Value = objPrinter.Name
Cells(R, 2).Value = objPrinter.Default
R = R + 1
Next

End Sub


Steve Yandl