Bouton d'option VBA et créer zone d'impression (code inclus)
m
Bonjour le forum,
J'ai créé deux cases d'options par le biais de DEVELOPPEUR, INSERER, CASE D'OPTION.
Mes deux boutons se nomment :
Case d'option 3 et Case d'option 2
J'aimerais définir par une macro que si le bouton 3 est coché alors définir zone d'impression et la meme chose pour le bouton 2 avec une autre zone d'impression
If OptionButtons2 = True Then
ActiveSheet.Unprotect Password:="boucherie"
Range("B37:H56").Select
Range("H7").Activate
ActiveSheet.PageSetup.PrintArea = "$B$37:$H$56"
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
ActiveWindow.SelectedSheets.PrintPreview
ActiveSheet.Protect "boucherie", DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowFormattingCells:=True, AllowSorting:=True, AllowFiltering:= _
True
Else
If OptionButtons3 = True Then
ActiveSheet.Unprotect Password:="boucherie"
Range("B10:H26").Select
Range("H7").Activate
ActiveSheet.PageSetup.PrintArea = "$B$10:$H$26"
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 130
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
ActiveWindow.SelectedSheets.PrintPreview
ActiveSheet.Protect "boucherie", DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowFormattingCells:=True, AllowSorting:=True, AllowFiltering:= _
True
End If
End IfSauf que ma case est cochée mais la macro va directement à la fin étant donné qu'elle a trouvé une valeur "vide" aux deux boutons.
Merci d'avance pour toute aide