Flop
XLDnaute Occasionnel
Bonjour j'ai récuperer cette macro sur ce ou un autre forum et elle marche très bien si ce n'est que quand je clique sur annuler l'impression se lance quand même. j'appelle la macro par la macro imprimer :
merci d'avance de votre aide.
'macro d'impression
Sub imprimer()
Call Select_Imprime
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
'####################################################################################'
Sub Select_Imprime()
'Liste les imprimantes, donne le choix et le nombre de pages à imprimer.
Dim BookName As String
BookName = Sheets("Accueil").Range("A2").Value
If Not Printer_Choice(BookName) Then Workbooks(BookName).Sheet(1).PrintOut Copies:=1
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
If Not nBook = "" Then
Workbooks(nBook).Activate
nbPages = ExecuteExcel4Macro("GET.DOCUMENT(50)") & msgPart1
End If
Actual_Printer = Left(ActivePrinter, Len(ActivePrinter) - 10)
Reply = MsgBox(msgPart2 & vbLf & Actual_Printer & " !" & _
vbLf & vbLf & msgPart3, 3 + 32 + 256, "Info utilisateur")
If Reply = vbYes Then
Application.Dialogs(xlDialogPrinterSetup).Show
MsgBox "Imprimante modifiée"
End If
If Reply = vbNo Then
Printer_Choice = True
End If
If Reply = vbCancel Then
Printer_Choice = True
End If
End Function
'####################################################################################'
merci d'avance de votre aide.
'macro d'impression
Sub imprimer()
Call Select_Imprime
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
'####################################################################################'
Sub Select_Imprime()
'Liste les imprimantes, donne le choix et le nombre de pages à imprimer.
Dim BookName As String
BookName = Sheets("Accueil").Range("A2").Value
If Not Printer_Choice(BookName) Then Workbooks(BookName).Sheet(1).PrintOut Copies:=1
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
If Not nBook = "" Then
Workbooks(nBook).Activate
nbPages = ExecuteExcel4Macro("GET.DOCUMENT(50)") & msgPart1
End If
Actual_Printer = Left(ActivePrinter, Len(ActivePrinter) - 10)
Reply = MsgBox(msgPart2 & vbLf & Actual_Printer & " !" & _
vbLf & vbLf & msgPart3, 3 + 32 + 256, "Info utilisateur")
If Reply = vbYes Then
Application.Dialogs(xlDialogPrinterSetup).Show
MsgBox "Imprimante modifiée"
End If
If Reply = vbNo Then
Printer_Choice = True
End If
If Reply = vbCancel Then
Printer_Choice = True
End If
End Function
'####################################################################################'