Listing installed ACTIVE printers

D

David Macdonald

Using the macros from word.mvps.org I have my list of the installed network
printers.
How can I get the list to show only those printers that are genuinely
available and on line (i.e. not including my home printer when I'm in the
office) ?
 
J

Jonathan West

David Macdonald said:
Using the macros from word.mvps.org I have my list of the installed
network
printers.
How can I get the list to show only those printers that are genuinely
available and on line (i.e. not including my home printer when I'm in the
office) ?

Karl Peterson has done a class moduile which enables you to know just about
all there is to know about a printer.

http://vb.mvps.org/samples/project.asp?id=PrnInfo

You need to use the IsOffline() property of the CPrnInfo class.
 
D

David Macdonald

Thanks for the link. Interesting stuff but in the meantime I found thi
http://www.eggheadcafe.com/conversation.aspx?messageid=30415740&threadid=30415642
and adapted it to end up with:
Sub PrinterList()
Dim strPrinterName As String
Dim strComputer As String
strPrinterName = Application.ActivePrinter
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from
Win32_Printer")
For Each objPrinter In colInstalledPrinters
If objPrinter.PrinterStatus = 1 Or objPrinter.PrinterStatus = 2 Or
objPrinter.PrinterStatus = 7 Then
Debug.Print "offline:" & objPrinter.name
Else
If InStr(strPrinterName, objPrinter.name) Then
Debug.Print objPrinter.name & "*"
Else
Debug.Print objPrinter.name
End If
End If
Next
End Sub

By substituting the debug.print with Combobox.additem, I have a list of all
the system printers with an asterisk following the default printer and
"offline" in front of any not connected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top