Impression plusieurs pages sans ouvrir plusieurs fois la boite de dialogue
F
Bonjour le Forum,
Après mettre lancer dans le VBA depuis mois d'une semaine j'aurais besoin d'un petit coup de main
J'ai codé ça :
Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then
Sheets("Tableau comparatif").PageSetup.Orientation = xlLandscape
Application.Dialogs(Excel.XlBuiltInDialog.xlDialogPrinterSetup).Show
Sheets("Tableau comparatif").PrintOut
With Worksheets("Tableau comparatif").PageSetup
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
Unload Me
End If
If CheckBox2.Value = True Then
Sheets("Tableau IJSS").PageSetup.Orientation = xlLandscape
Application.Dialogs(Excel.XlBuiltInDialog.xlDialogPrinterSetup).Show
Sheets("Tableau IJSS").PrintOut
With Worksheets("Tableau IJSS").PageSetup
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
Unload Me
End If
If CheckBox3.Value = True Then
Sheets("Tableau valorisation").PageSetup.Orientation = xlLandscape
Application.Dialogs(Excel.XlBuiltInDialog.xlDialogPrinterSetup).Show
Sheets("Tableau IJSS").PrintOut
With Worksheets("Tableau IJSS").PageSetup
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
Unload Me
Mais voilà le soucis, quand je coche les 3 cases il y a 3 fois la boite de dialogue "impression" qui s'ouvre c'est possible qu'elle ne s'ouvre qu'une seul fois pour l'impression des pages choisies?
Merci à tous
G
Salut,
Essaie ceci : (Au lieu de mettre la fonction dans chaqu'un de tes "If" je le met une fois au début)
Private Sub CommandButton1_Click()
Application.Dialogs(Excel.XlBuiltInDialog.xlDialogPrinterSetup).Show
If CheckBox1.Value = True Then
Sheets("Tableau comparatif").PageSetup.Orientation = xlLandscape
Sheets("Tableau comparatif").PrintOut
With Worksheets("Tableau comparatif").PageSetup
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
Unload Me
End If
If CheckBox2.Value = True Then
Sheets("Tableau IJSS").PageSetup.Orientation = xlLandscape
Sheets("Tableau IJSS").PrintOut
With Worksheets("Tableau IJSS").PageSetup
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
Unload Me
End If
If CheckBox3.Value = True Then
Sheets("Tableau valorisation").PageSetup.Orientation = xlLandscape
Sheets("Tableau IJSS").PrintOut
With Worksheets("Tableau IJSS").PageSetup
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
Unload Me
F
Erreur d’exécution 1004:
La méthode PrintOut de la classe worksheet a échoué