Bonsoir à tout le forum
J'ai une macro qui me sert à mettre un entête et un pied de page sur la feuille sélectionnée puis
en même temps à imprimer une plage sélectionnée.
Mais je ne comprends pas car l'impression ne se fait pas sur la sélection mais sur la feuille entière.
Je vous joins mon code, si quelqu'un y voit une anomalie:
Sub MaMacro2()
'
Dim info As String
info = ActiveSheet.Name & Chr(32) & Format(Date, 'yyyy')
Range('A1:AG50').Select
Application.ScreenUpdating = False
With ActiveSheet.PageSetup
.PrintTitleRows = ''
.PrintTitleColumns = ''
End With
ActiveSheet.PageSetup.PrintArea = '$A$1:$AG$50'
With ActiveSheet.PageSetup
.CenterHeader = '&''Comic Sans MS,Gras''&16' & info
.CenterFooter = 'Imprimé le &D à &T'
.LeftMargin = Application.InchesToPoints(0.196850393700787)
.RightMargin = Application.InchesToPoints(0.196850393700787)
.TopMargin = Application.InchesToPoints(0.590551181102362)
.BottomMargin = Application.InchesToPoints(0.590551181102362)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Selection.PrintOut Copies:=1, Collate:=True
Application.ScreenUpdating = True
End Sub
Voilà j'attends votre avis sur la macro
J'ai une macro qui me sert à mettre un entête et un pied de page sur la feuille sélectionnée puis
en même temps à imprimer une plage sélectionnée.
Mais je ne comprends pas car l'impression ne se fait pas sur la sélection mais sur la feuille entière.
Je vous joins mon code, si quelqu'un y voit une anomalie:
Sub MaMacro2()
'
Dim info As String
info = ActiveSheet.Name & Chr(32) & Format(Date, 'yyyy')
Range('A1:AG50').Select
Application.ScreenUpdating = False
With ActiveSheet.PageSetup
.PrintTitleRows = ''
.PrintTitleColumns = ''
End With
ActiveSheet.PageSetup.PrintArea = '$A$1:$AG$50'
With ActiveSheet.PageSetup
.CenterHeader = '&''Comic Sans MS,Gras''&16' & info
.CenterFooter = 'Imprimé le &D à &T'
.LeftMargin = Application.InchesToPoints(0.196850393700787)
.RightMargin = Application.InchesToPoints(0.196850393700787)
.TopMargin = Application.InchesToPoints(0.590551181102362)
.BottomMargin = Application.InchesToPoints(0.590551181102362)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Selection.PrintOut Copies:=1, Collate:=True
Application.ScreenUpdating = True
End Sub
Voilà j'attends votre avis sur la macro