'Liste les imprimantes, donne le choix et le nombre de pages à imprimer.
'Michel Pierron, mpfe
Sub Imprime()
Dim BookName As String
BookName = Workbooks("Machin.xls")
If Not Printer_Choice(BookName) Then
Workbooks(BookName).Sheet(1).PrintOut copies:=1
Else
MsgBox "Impression abandonnée"
End If
End Sub
'Sélection imprimante pour impression
Function Printer_Choice(nBook As String) As Boolean
Const msgPart1 = " page(s) à imprimer sur "
Const msgPart2 = "Imprimante active :"
Const msgPart3 = "Voulez-vous changer d'imprimante ?"
Dim Reply As Byte, Actual_Printer As String, nbPages As String
Printer_Choice = True 'pour éviter l'erreur signalée plus bas
If Not nBook = "" Then
Workbooks(nBook).Activate
nbPages = ExecuteExcel4Macro("GET.DOCUMENT(50)") & msgPart1
End If
Actual_Printer = Application.ActivePrinter
Reply = MsgBox(nbPages & msgPart2 & vbLf & Actual_Printer & " !" & _
vbLf & vbLf & msgPart3, 3 + 32 + 256, "Info utilisateur")
' ici erreur si on sort de la boite de dialogue par Annuler
If Reply = vbYes Then Application.Dialogs(xlDialogPrinterSetup).Show
If Reply = vbCancel Then Printer_Choice = True
End Function