XL 2016 impression USERFORM en pdf

MOEZ-TUN

XLDnaute Occasionnel
Bonjour
j'utilisé cet macro pour imprimer une USERFORM
Sub impressionForm()
Dim x, tbl(), i, texte
x = 0
With CreateObject("WScript.Network")
Set imprimantes = .EnumPrinterConnections
For i = 0 To imprimantes.Count - 1
If InStr(LCase(imprimantes(i)), "pdf") > 0 Then ReDim Preserve tbl(0 To x): tbl(x) = imprimantes(i): texte = texte & x & "--" & imprimantes(i) & vbCrLf: x = x + 1
Next
i = InputBox("choissisez une imprimante " & vbCrLf & texte, "impression userform")
If i <> "" Then
.SetDefaultPrinter tbl(Val(i))
UserForm1.printform

End If
End With
End Sub

Mais j'arrive pas a ajouter une troisième choix de type de l'imprimante , ni a définir le chemin et nom de fichier a imprimé.

Merci pour voter support
 

i20100_

XLDnaute Nouveau
Bonjour,

dans ta macro il y a un seul choix de type de l'imprimante c'est "PDF"
VB:
If InStr(LCase(imprimantes(i)), "pdf") > 0

pour en ajouter d'autres comme par exemple "hp" ou "cannon",
Code:
If InStr(LCase(imprimantes(i)), "pdf") > 0 Or InStr(LCase(imprimantes(i)), "hp") > 0 Or InStr(LCase(imprimantes(i)), "canon") > 0 Then ReDim Preserve tbl(0 To x): tbl(x) = imprimantes(i): texte = texte & x & "--" & imprimantes(i) & vbCrLf: x = x + 1
 

Discussions similaires

Statistiques des forums

Discussions
311 719
Messages
2 081 881
Membres
101 829
dernier inscrit
listener75