Sub testLandscape()
Dim Rng As Range, Ws As Worksheet
'au depart les rng et ws sont nothing,ils sont determinés dans la createPage A4
createPageA4 xlLandscape, Rng, Ws
'du coup j'ai la plage et la feuille disponible ici
'ici on pourrait coller la capture et strtcher la shapes(1) dans ws
'je met de la couleur pour voir
Rng.Interior.Color = RGB(255, 245, 240)
Rng.BorderAround 1, 2, 3
Ws.PrintPreview
Application.DisplayAlerts = False
Ws.Delete
Application.DisplayAlerts = True
End Sub
Sub testportrait()
Dim Rng As Range, Ws As Worksheet
'au depart les rng et ws sont nothing,ils sont determinés dans la createPage A4
createPageA4 xlPortrait, Rng, Ws
'du coup j'ai la plage et la feuille disponible ici
'ici on pourrait coller la capture et strtcher la shapes(1) dans ws
'Pour l'exemple je met de la couleur pour voir
Rng.Interior.Color = RGB(255, 245, 240)
Rng.BorderAround 1, 2, 3
Ws.PrintPreview
Application.DisplayAlerts = False
Ws.Delete
Application.DisplayAlerts = True
End Sub
Sub createPageA4(sens, Rng As Range, Ws As Worksheet)
Set Ws = Sheets.Add
If sens = xlLandscape Then
Set Rng = Ws.Range("A1:M40")
Rng.ColumnWidth = 10.71
Rng.RowHeight = 15
Rng.Cells(Rng.Rows.Count, 1).RowHeight = 15.75
Rng.Cells(Rng.Columns.Count).ColumnWidth = 9.29
Else
Set Rng = Ws.Range("A1:I57")
Rng.ColumnWidth = 10.71
Rng.RowHeight = 15
Rng.Cells(Rng.Rows.Count, 1).RowHeight = 10.25
Rng.Cells(Rng.Columns.Count).ColumnWidth = 11
End If
With Ws.PageSetup
.PrintArea = Rng.Address
.Orientation = sens
.LeftMargin = 0
.TopMargin = 0
.RightMargin = 0
.BottomMargin = 0
.HeaderMargin = 0
.FooterMargin = 0
.Zoom = 100
Ws.ResetAllPageBreaks 'juste au cas ou
.CenterHorizontally = 1
.CenterVertically = 1
End With
End Sub