Option Explicit
Dim HauteurPagePoints As Single
Dim LargeurPagePoints As Single
Sub Test()
CalculeHauteurLargeur
Dim ColDep As Long, LigDep As Long
Dim coefLargeur
ColDep = 2: LigDep = 1 'Ligne et colonne de départ
'une plage qui commence en ligne1 colonne 2 et fini en ligne 55 et colonne 4 (F)
With Range(Cells(LigDep, ColDep), Cells(LigDep + 54, ColDep + 3))
'Les unités de largeur de colonnes (columnWidth)sont proportionnelles a une police normale
'De plus la propriété Width exprimée en points n'est qu'en lecture seule
'Alors que RowHeight et Row.Height sont toutes deux exprimées en point
.Columns(1).EntireColumn.ColumnWidth = 20
coefLargeur = .Columns(1).Width / 20
.Columns.EntireColumn.ColumnWidth = (LargeurPagePoints / 4) / coefLargeur
.Rows.EntireRow.RowHeight = HauteurPagePoints / 55
ActiveSheet.PageSetup.PrintArea = .Address
End With
End Sub
Sub CalculeHauteurLargeur()
'Hauteur et largeur d'une page A4
'Sachant qu'un pouce = 2.54 cm
HauteurPagePoints = Application.InchesToPoints(29.7 * 1 / 2.54)
LargeurPagePoints = Application.InchesToPoints(21 * 1 / 2.54)
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.25) 'marge gauche
.RightMargin = Application.InchesToPoints(0.25) 'marge droite
.TopMargin = Application.InchesToPoints(0.31) 'marge haut
.BottomMargin = Application.InchesToPoints(0.31) 'marge bas
.HeaderMargin = Application.InchesToPoints(0.19) 'marge tout en haut
.FooterMargin = Application.InchesToPoints(0.19) 'marge tout en bas
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
HauteurPagePoints = HauteurPagePoints - .TopMargin - .FooterMargin
LargeurPagePoints = LargeurPagePoints - .LeftMargin - .RightMargin
End With
End Sub