Fich excel/vba

mell01 Messages postés 72 Date d'inscription lundi 6 juin 2005 Statut Membre Dernière intervention 15 mai 2006 - 16 févr. 2006 à 15:00
nanougat Messages postés 40 Date d'inscription samedi 6 novembre 2004 Statut Membre Dernière intervention 26 octobre 2007 - 20 févr. 2006 à 16:12
bonjour,
j'aimerai savoir comment faire pour définir une mise en page dans vba avant l'impression d'un fichier excel créé a partir vba.
Par exemple je voudrais le mettre en format A3,centrer le contenu,afficher le quadrillage.
Voilà merci d'avance!

1 réponse

nanougat Messages postés 40 Date d'inscription samedi 6 novembre 2004 Statut Membre Dernière intervention 26 octobre 2007
20 févr. 2006 à 16:12
Bonjour,



Essaies cette procédure



Sub formatA3



Range("A1:F13").Select
''''''''''' A1:F13 étant la zone à imprimer. Pour définir
cette zone, tu te mets sur la première cellule en haut et à gauche et
tu te sers de la fonction "currentregion" qui récupère la dernière
cellule en bas à droite . Attention cela te prend toutes les cellules
occupées.



Selection.Borders(xlDiagonalDown).LineStyle = xlNone

Selection.Borders(xlDiagonalUp).LineStyle = xlNone

With Selection.Borders(xlEdgeLeft)

.LineStyle = xlContinuous

.Weight = xlThin

.ColorIndex = xlAutomatic

End With

With Selection.Borders(xlEdgeTop)

.LineStyle = xlContinuous

.Weight = xlThin

.ColorIndex = xlAutomatic

End With

With Selection.Borders(xlEdgeBottom)

.LineStyle = xlContinuous

.Weight = xlThin

.ColorIndex = xlAutomatic

End With

With Selection.Borders(xlEdgeRight)

.LineStyle = xlContinuous

.Weight = xlThin

.ColorIndex = xlAutomatic

End With

With Selection.Borders(xlInsideVertical)

.LineStyle = xlContinuous

.Weight = xlThin

.ColorIndex = xlAutomatic

End With

With Selection.Borders(xlInsideHorizontal)

.LineStyle = xlContinuous

.Weight = xlThin

.ColorIndex = xlAutomatic

End With

With ActiveSheet.PageSetup

.PrintTitleRows = ""

.PrintTitleColumns = ""

End With

ActiveSheet.PageSetup.PrintArea = "$A$1:$F$13"

With ActiveSheet.PageSetup

.LeftHeader = ""

.CenterHeader = ""

.RightHeader = ""

.LeftFooter = ""

.CenterFooter = ""

.RightFooter = ""

.LeftMargin = Application.InchesToPoints(0.78740157480315)

.RightMargin = Application.InchesToPoints(0.78740157480315)

.TopMargin = Application.InchesToPoints(0.984251968503937)

.BottomMargin = Application.InchesToPoints(0.984251968503937)

.HeaderMargin = Application.InchesToPoints(0.511811023622047)

.FooterMargin = Application.InchesToPoints(0.511811023622047)

.PrintHeadings = False

.PrintGridlines = False

.PrintComments = xlPrintNoComments

.PrintQuality = 600

.CenterHorizontally = True

.CenterVertically = True

.Orientation = xlPortrait

.Draft = False

.PaperSize = xlPaperA3

.FirstPageNumber = xlAutomatic

.Order = xlDownThenOver

.BlackAndWhite = False

.Zoom = False

.FitToPagesWide = 1

.FitToPagesTall = 1

End With

End Sub
0
Rejoignez-nous