Option Explicit
Sub test()
Dim Message As String, Etat_Imprimante As String
Dim Nom_Ordi As String, Reponse As String
Dim Objet_WMI_Service As Object
Dim Liste_Imprimantes_Installées As Object
Dim Imprimante As Object
encore:
Message = ""
Range("AX6000").PrintOut 'Forcer mise a jour du statut de l'imprimante
Nom_Ordi = "."
Set Objet_WMI_Service = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Nom_Ordi & "\root\cimv2")
Set Liste_Imprimantes_Installées = Objet_WMI_Service.ExecQuery("Select * from Win32_Printer")
For Each Imprimante In Liste_Imprimantes_Installées
If InStr(Application.ActivePrinter, Imprimante.Name) Then
Etat_Imprimante = Imprimante.printerStatus
Message = "L'imprimante " & Imprimante.Name
Select Case Imprimante.printerStatus
Case 3
Message = Message & " est au repos"
Case 4
Message = Message & " est en cours d'impression"
Case 5
Message = Message & " est en rechauffement"
Case Else
Message = Message & " est hors ligne"
End Select
End If
Next
Set Liste_Imprimantes_Installées = Nothing
Set Objet_WMI_Service = Nothing
Select Case Etat_Imprimante
Case 3, 4, 5
'lance la vraie impression
Range("A1:X100").PrintOut
Case Else
Reponse = MsgBox(Message & vbCrLf & "Veuillez relancer lorsque celle ci sera ok", vbOKCancel, "Etat de l'imprimante")
If Reponse = vbOK Then GoTo encore
End Select
End Sub