Sub ImpressionApercu() 'ceci ouvre direct aperçu pour imprime
ActiveSheet.PageSetup.PrintArea = [A1].CurrentRegion.Address
ActiveWindow.SelectedSheets.PrintPreview
End Sub
Sub ImpressionLPT() 'ceci ouvre la boite de dialog imprimante
Feuil$ = "Feuil1" '<<<<<< nom de la feuille
Rang$ = "A1:B10"
LPTZoneImpression$ = Sheets(Feuil$).Range(Rang$) '<<<<<< range de données
LPTOrientationPage = xlPortrait '<<<<<< ou xlLandscape (paysage)
LPTSautDePage = 0 '<<<<<< ou 1 pour autorisation des sauts pages
MsgEntete$ = "bonjour" '<<<<<< voir avec message en entête ou pas =""
' init...
InitImprimante Feuil$, MsgEntete$, LPTZoneImpression$, LPTOrientationPage, LPTSautDePage
' boite de dialogue...
Application.Dialogs(xlDialogPrint).Show
End Sub
Sub InitImprimante(Feuil$, MsgEntete$, LPTZoneImpression$, LPTOrientationPage, LPTSautDePage)
EspacH = 0: If MsgEntete$ > "" Then EspacH = 1
With Sheets(Feuil$).PageSetup
.Zoom = False 'pas true sinon FitToPagesTall invalide
If LPTSautDePage Then
.FitToPagesTall = False 'permet le saut de page si trop haut
Else
.FitToPagesTall = 1 'impose sur la hauteur de la page
End If
.FitToPagesWide = 1 'impose sur la largeur de la page(toujours)
.Orientation = LPTOrientationPage
.CenterHorizontally = False
.CenterVertically = False
If LPTZoneImpression$ > "" Then .PrintArea = LPTZoneImpression$ 'sinon page entière
.LeftHeader = MsgEntete$
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.TopMargin = Application.CentimetersToPoints(EspacH)
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
End With
End Sub