1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
Option Explicit
Sub Lister_Proprietes_Imprimantes()
Dim objWMIService As Object, colInstalledPrinters As Object
Dim objPrinter As Object
Dim nomPC As String, r As Long, c As Long
ShPrinter.Cells.Clear
nomPC = "."
Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & nomPC & "\root\cimv2")
Set colInstalledPrinters = objWMIService. _
ExecQuery("Select * from Win32_Printer")
r = 2: c = 1
With ShPrinter
.Cells(r, c) = "Attributes"
.Cells(r + 1, c) = "Availability"
.Cells(r + 2, c) = "AveragePagesPerMinute"
.Cells(r + 3, c) = "Caption"
.Cells(r + 4, c) = "ConfigManagerErrorCode"
.Cells(r + 5, c) = "ConfigManagerUserConfig"
.Cells(r + 6, c) = "CreationClassName"
.Cells(r + 7, c) = "DefaultPriority"
.Cells(r + 8, c) = "Description"
.Cells(r + 9, c) = "DetectedErrorState"
.Cells(r + 10, c) = "DeviceID"
.Cells(r + 11, c) = "DriverName"
.Cells(r + 12, c) = "ErrorCleared"
.Cells(r + 13, c) = "ErrorDescription"
.Cells(r + 14, c) = "HorizontalResolution"
.Cells(r + 15, c) = "InstallDate"
.Cells(r + 16, c) = "JobCountSinceLastReset"
.Cells(r + 17, c) = "LanguagesSupported"
.Cells(r + 18, c) = "LastErrorCode"
.Cells(r + 19, c) = "Location"
.Cells(r + 20, c) = "Name"
.Cells(r + 21, c) = "PNPDeviceID"
.Cells(r + 22, c) = "PortName"
.Cells(r + 23, c) = "PowerManagementCapabilities"
.Cells(r + 24, c) = "PowerManagementSupported"
.Cells(r + 25, c) = "PrinterState"
.Cells(r + 26, c) = "PrinterStatus"
.Cells(r + 27, c) = "PrintJobDataType"
.Cells(r + 28, c) = "PrintProcessor"
.Cells(r + 29, c) = "SeparatorFile"
.Cells(r + 30, c) = "ServerName"
.Cells(r + 31, c) = "ShareName"
.Cells(r + 32, c) = "SpoolEnabled"
.Cells(r + 33, c) = "StartTime"
.Cells(r + 34, c) = "Status"
.Cells(r + 35, c) = "StatusInfo"
.Cells(r + 36, c) = "SystemCreationClassName"
.Cells(r + 37, c) = "SystemName"
.Cells(r + 38, c) = "TimeOfLastReset"
.Cells(r + 39, c) = "UntilTime"
.Cells(r + 40, c) = "VerticalResolution"
.Cells(r + 41, c) = "PaperSizesSupported"
.Cells(r + 42, c) = "PrinterPaperNames"
' .Cells(r + 43, c) = "Capabilities"
' .Cells(r + 44, c) = "CapabilityDescriptions"
End With
c = c + 1
For Each objPrinter In colInstalledPrinters
With ShPrinter
.Cells(r, c) = objPrinter.Attributes
.Cells(r + 1, c) = objPrinter.Availability
.Cells(r + 2, c) = objPrinter.AveragePagesPerMinute
.Cells(r + 3, c) = objPrinter.Caption
.Cells(r + 4, c) = objPrinter.ConfigManagerErrorCode
.Cells(r + 5, c) = objPrinter.ConfigManagerUserConfig
.Cells(r + 6, c) = objPrinter.CreationClassName
.Cells(r + 7, c) = objPrinter.DefaultPriority
.Cells(r + 8, c) = objPrinter.Description
.Cells(r + 9, c) = objPrinter.DetectedErrorState
.Cells(r + 10, c) = objPrinter.DeviceID
.Cells(r + 11, c) = objPrinter.DriverName
.Cells(r + 12, c) = objPrinter.ErrorCleared
.Cells(r + 13, c) = objPrinter.ErrorDescription
.Cells(r + 14, c) = objPrinter.HorizontalResolution
.Cells(r + 15, c) = objPrinter.InstallDate
.Cells(r + 16, c) = objPrinter.JobCountSinceLastReset
.Cells(r + 17, c) = objPrinter.LanguagesSupported
.Cells(r + 18, c) = objPrinter.LastErrorCode
.Cells(r + 19, c) = objPrinter.Location
.Cells(r + 20, c) = objPrinter.Name
.Cells(r + 21, c) = objPrinter.PNPDeviceID
.Cells(r + 22, c) = objPrinter.PortName
.Cells(r + 23, c) = objPrinter.PowerManagementCapabilities
.Cells(r + 24, c) = objPrinter.PowerManagementSupported
.Cells(r + 25, c) = objPrinter.PrinterState
.Cells(r + 26, c) = objPrinter.PrinterStatus
.Cells(r + 27, c) = objPrinter.PrintJobDataType
.Cells(r + 28, c) = objPrinter.PrintProcessor
.Cells(r + 29, c) = objPrinter.SeparatorFile
.Cells(r + 30, c) = objPrinter.ServerName
.Cells(r + 31, c) = objPrinter.ShareName
.Cells(r + 32, c) = objPrinter.SpoolEnabled
.Cells(r + 33, c) = objPrinter.StartTime
.Cells(r + 34, c) = objPrinter.Status
.Cells(r + 35, c) = objPrinter.StatusInfo
.Cells(r + 36, c) = objPrinter.SystemCreationClassName
.Cells(r + 37, c) = objPrinter.SystemName
.Cells(r + 38, c) = objPrinter.TimeOfLastReset
.Cells(r + 39, c) = objPrinter.UntilTime
.Cells(r + 40, c) = objPrinter.VerticalResolution
.Cells(r + 41, c) = objPrinter.PaperSizesSupported
.Cells(r + 42, c) = objPrinter.PrinterPaperNames
' .Cells(r + 43, c) = objPrinter.Capabilities
' .Cells(r + 44, c) = objPrinter.CapabilityDescriptions
End With
c = c + 1
Next objPrinter
End Sub |
Partager