HSV
Inventaris
- Lid geworden
- 18 jul 2008
- Berichten
- 20.991
- Office versie
- Bèta Insider Office 365
Zo werkt het bij mij.
Code:
Private Sub CommandButton1_Click()
If PrinterReady(Application.ActivePrinter) Then
Sheets.PrintPreview
Else
MsgBox "De printer is niet gereed"
End If
End Sub
Function PrinterReady(PRT As String) As Boolean
Dim strComputer As String
Dim objWMIService
Dim colInstalledPrinters
Dim objPrinter
Dim printer
strComputer = "."
printer = PRT
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer", , 48)
For Each objPrinter In colInstalledPrinters
If Split(objPrinter.Path_, "=")(1) = """" & Replace(printer, " op Ne03:", "") & """" And Not objPrinter.WorkOffline Then
PrinterReady = True
End If
Next
End Function