1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| Sub Impression()
Dim BLOUP As Boolean
Dim BLOU As Boolean
'Impression de la 1ère page en portrait
'--------------------------------------
ActiveSheet.Select
Select Case MsgBox("Souhaitez vous imprimer le descriptif ?", vbYesNo, "Descriptif")
Case vbYes
BLOUP = True
Case vbNo
BLOUP = False
End Select
If BLOUP = True Then
DerRows1 = Range("C65536").End(xlUp).Row
'MsgBox DerRows1
DerRows1 = DerRows1 + 2
Range(Cells(1, 1), Cells(DerRows1, 5)).Select 'définition de la plage de cellules constituant la 1ère page5
ActiveSheet.PageSetup.PrintArea = "$B$2:$E$" & DerRows1 'définition de la zone d'impression
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.Orientation = xlPortrait
.LeftMargin = Application.InchesToPoints(0.2)
.RightMargin = Application.InchesToPoints(0.2)
.TopMargin = Application.InchesToPoints(0.2)
.BottomMargin = Application.InchesToPoints(0.2)
.HeaderMargin = Application.InchesToPoints(0.2)
.FooterMargin = Application.InchesToPoints(0.2)
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
ActiveSheet.PageSetup.Orientation = xlPortrait 'mise au format portrait
'ActiveSheet.PageSetup.CenterHorizontally = True 'centrage horizontal de la feuille
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True 'impression
End If
'Impression de la 2ème page en paysage
'-------------------------------------
Select Case MsgBox("Souhaitez vous imprimer la liste ?", vbYesNo, "Liste")
Case vbYes
BLOU = vbTrue
Case vbNo
BLOU = vbFalse
End Select
If BLOU = True Then
ActiveSheet.Select
DerRows2 = Range("H65536").End(xlUp).Row
'MsgBox DerRows2
Range(Cells(2, 8), Cells(DerRows2 + 1, 30)).Select 'définition de la plage de cellules constituant la 2ème page
ActiveSheet.PageSetup.PrintArea = "$H$2:$AC$" & DerRows2 'définition de la zone d'impression
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.LeftMargin = Application.InchesToPoints(0.2)
.RightMargin = Application.InchesToPoints(0.2)
.TopMargin = Application.InchesToPoints(0.2)
.BottomMargin = Application.InchesToPoints(0.2)
.HeaderMargin = Application.InchesToPoints(0.2)
.FooterMargin = Application.InchesToPoints(0.2)
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
ActiveSheet.PageSetup.Orientation = xlLandscape 'mise au format paysage
'ActiveSheet.PageSetup.CenterHorizontally = True 'centrage horizontal de la feuille
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True 'impression
End If
End Sub |
Partager