View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Michel Pierron Michel Pierron is offline
external usenet poster
 
Posts: 214
Default List of printers

Hi Tom,
For iCount = 0 To oPrinters.Count - 1 Step 2
Debug.Print "Printer Port " & oPrinter.Item(iCount) & " = " &
oPrinter.Item(iCount + 1)
Next

MP

"Tom" a écrit dans le message de
...
Hi

I'd like to get a array of all installed printers incl. the connected

port.
The array should look like this:

HP LaserJet 6P on LPT1:
Adobe PDF on Ne03:
SnagIt 6 on Ne00:


I already have the following procedure, but this code doesn't return the
connected port:

Private Sub ListPrinters()
Dim wshNetwork As Object
Dim oDrives As Object
Dim oPrinters As Object
Dim iCount As Integer
Dim sCurrentprinter As String
sCurrentprinter = Application.ActivePrinter
Set wshNetwork = CreateObject("WScript.Network")
Set oDrives = wshNetwork.EnumNetworkDrives
Set oPrinters = wshNetwork.EnumPrinterConnections
For iCount = 0 To oPrinters.Count - 1 Step 2
Debug.Print oPrinters.Item(iCount + 1)
Next
End Sub


Many thanks in advance.

Tom