J’ai un tableau que je voudrai imprimer mais j’ai un souci pour la mise en page.
Après avoir défini les marges, impression sur chaque page des 5 premières lignes, impression jusqu’à la dernière ligne remplie, je voudrai qu’il m’imprime que 28 lignes par pages, mais je ne sais pas comment faire, car il imprime toujours sur 1 seule feuille.
Si quelqu’un à une idée.
Merci
Private Sub Impression_A4_Click()
Dim DerLig As Long
'Impression au format A4
Set aff = Sheets("affectation")
With aff
DerLig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
With .PageSetup
.PrintTitleRows = "$A$1:$F$5" 'Copie 5 lignes sur chaque page
.PrintArea = "A1:F" & DerLig ‘Impression jusqu’à dernière ligne
.PaperSize = xlPaperA4 'Format A4
.Orientation = xlPortrait 'Impression portrait
.LeftMargin = Application.InchesToPoints(0.25) 'définition des marges
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.25)
.BottomMargin = Application.InchesToPoints(0.25)
.Zoom = False
.FitToPagesWide = 1 'adaptation largeur feuille
End With
.PrintPreview
End With
End Sub
Option Explicit
Private Sub Impression_A4_Click()
Dim DerLig As Long, i As Long, aff As Worksheet
'Impression au format A4
Set aff = Sheets("affectation")
With aff
DerLig = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
.DisplayAutomaticPageBreaks = False
For i = 28 To DerLig Step 23 'Saut de page après 28 lignes
.HPageBreaks.Add before:=Rows(i + 1)
Next i
With .PageSetup
.PrintTitleRows = "$A$1:$F$5" 'Copie 5 lignes sur chaque page
.PrintArea = "A1:F" & DerLig 'Impression jusqu’à dernière ligne
.PaperSize = xlPaperA4 'Format A4
.Orientation = xlPortrait 'Impression portrait
.LeftMargin = Application.InchesToPoints(0.25) 'définition des marges
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.25)
.BottomMargin = Application.InchesToPoints(0.25)
.Zoom = False
.FitToPagesWide = 1 'adaptation largeur feuille
End With
.PrintPreview
End With
End Sub