Bonjour,
Je suis à la recherche d'une macro qui me donne le nom des différentes imprimantes installées.
J'ai trouvé une macro toute faite sur msdn mais celle ci ne marche pas. L'objet Printer n'est pas défini. Peut être une référence à ajouter mais je ne trouve pas laquelle...
Quelqu'un peut m'aider ?
Voici le code que j'ai pris :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Sub ShowPrinters() Dim strCount As String Dim strMsg As String Dim prtLoop As Printer On Error GoTo ShowPrinters_Err If Printers.Count > 0 Then ' Get count of installed printers. strMsg = "Printers installed: " &; Printers.Count &; vbCrLf &; vbCrLf ' Enumerate printer system properties. For Each prtLoop In Application.Printers With prtLoop strMsg = strMsg _ &; "Device name: " &; .DeviceName &; vbCrLf _ &; "Driver name: " &; .DriverName &; vbCrLf _ &; "Port: " &; .Port &; vbCrLf &; vbCrLf End With Next prtLoop Else strMsg = "No printers are installed." End If ' Display printer information. MsgBox Prompt:=strMsg, Buttons:=vbOKOnly, Title:="Installed Printers" ShowPrinters_End: Exit Sub ShowPrinters_Err: MsgBox Prompt:=Err.Description, Buttons:=vbCritical &; vbOKOnly, _ Title:="Error Number " &; Err.Number &; " Occurred" Resume ShowPrinters_End End Sub
Partager