VBA Excel Changement d''imprimante impossible
Bonjour,
Avec VBA Excel 2010 - Windows 10
Après une journée de tentatives, je ne parviens pas à imprimer ma Userform "Page" sur l'iune des mprimantes que je veux sélectionner !
soit via xlDialogPrinterSetup, soit xlDialogPrint ?
Le code est pourtant simple ? Merci de votre aide, j'ai cherché sur de nombreux sites, aucune solution proposée ne marche.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
Private Sub CommandButton1_Click()
SelectPrinter
Page.PrintForm
End Sub
Public Sub SelectPrinter()
Dim fileOK As Boolean
Dim ActuelleImpr As String
With Application
ActuelleImpr = .ActivePrinter
fileOK = .Dialogs(xlDialogPrinterSetup).Show
' fileOK = .Dialogs(xlDialogPrint).Show
NewPrinter = .ActivePrinter
End With
If Not fileOK Then
MsgBox "User cancelled"
Else
NewPrinter = Application.ActivePrinter ' NewPrinter est une var Public
End If
MsgBox "NewPrinter est : " + NewPrinter
End Sub |