Sub ImprimerTableaux()
'
Dim Plage1 As Range, Plage2 As Range
Dim ligne As Long
Set Plage1 = Sheets("Feuil1").Range("B6").CurrentRegion
Set Plage2 = Sheets("Feuil1").Range("Q20").CurrentRegion
'destruction des images éventuellement existantes dans la feuil2
Sheets("Feuil2").Activate
With ActiveSheet
Dim largeur As Single
largeur = Application.CentimetersToPoints(29.7)
Do While .Pictures.Count > 0
.Pictures(1).Delete
Loop
With .PageSetup
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
'Copie la plage 1 en tant qu'image
Plage1.CopyPicture xlPrinter
'Coller l'image dans la feuil2
.Paste Range("A1")
'Récupérer le numéro de la dernière ligne occupée par l'image collée
With .Pictures(.Pictures.Count)
.ShapeRange.LockAspectRatio = msoTrue
'.Height = .Height * 0.9
.Width = Range(Cells(1, 1), ActiveSheet.VPageBreaks(1).Location.Offset(, -1)).Width
' ligne = .BottomRightCell.Row
End With
'Copier la plage 2 en tan qu'image
' Plage2.CopyPicture xlPrinter
'coller 3 lignes sous l'autre
.Paste Range("A" & ligne + 3)
'Exportation au format pdf
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\testimpression.pdf", Quality:=xlQualityStandard
End With
End Sub