OVH Cloud OVH Cloud

changer l'imrimante dans word d'après excel

1 réponse
Avatar
xavier
BOnjour,



Je souhaiterais changer l'imprimante et ne pas prendre=20
celle par d=E9faut pour imprimer un document word que j'ai=20
lanc=E9 depuis une macro excel

merci

1 réponse

Avatar
isabelle
bonjour Xavier,

il y a cette macro de Michel retrouver ici,

http://groups.google.com/groups?q=imprimante+par+default+group:microsoft.public.fr.excel&hl=fr&lr=&ie=UTF-8&scoring=d&selm=ucI5Rz4TEHA.2908%40TK2MSFTNGP10.phx.gbl&rnum=1

Sub PrinterDefault()
Dim Text$, i%, j%, tmp, PrnList As Object, PrnDef$, u%
PrnDef = Application.ActivePrinter
Text = "Sélectionnez l'imprimante par défaut voulue" & vbLf _
& "(Entrez le numéro de ligne correspondant) !" & vbLf & vbLf
With CreateObject("WScript.Network")
Set PrnList = .EnumPrinterConnections
j = PrnList.Count
For i = 0 To j - 1 Step 2
Text = Text & (i / 2) & " -> "
Text = Text & PrnList(i + 1)
If InStr(1, PrnDef, PrnList(i + 1)) Then
Text = Text & " (par défaut)": u = i / 2
End If
Text = Text & vbLf
Next
Again:
tmp = InputBox(Text, "Selection imprimante par default", u)
If tmp = "" Then GoTo Fin
tmp = CInt(tmp)
If tmp < 0 Or tmp > (j / 2) - 1 Then GoTo Again
.SetDefaultPrinter PrnList(tmp * 2 + 1)
End With
Fin: Set PrnList = Nothing
End Sub 'MP

isabelle


BOnjour,

Je souhaiterais changer l'imprimante et ne pas prendre
celle par défaut pour imprimer un document word que j'ai
lancé depuis une macro excel

merci