Aide pour une mise en page avec VBA

clara95 Messages postés 9 Statut Membre -  
lermite222 Messages postés 9042 Statut Contributeur -
Bonjour,
Avec la syntaxe with end with , je veux créer une procedure qui permet de definir ma mise en page de ma feuille et redimensionner les colonnes et lancer limpression
Mais dès ma 3ième ligne ça m'ecrit erreur d'execution '1004' Erreur definie par l'application ou par l'objet
Pouvez-vous m'aider à trouver mon erreur et les modification à apporter s'il vous plait?

Voici mon programme:

Sub MiseEnPagedelafeuille()
With ActiveSheet
With .PageSetup
.Orientation = xLandscape
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.LeftHeader = ""
.CenterHeader = "&A"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "Page & P"
.RightFooter = ""
End With
.Colums.EntireColumn.AutoFit
.Rows.EntireRow.AutoFit

ActiveWindow.SelectSheets.PrintPreview
End With
End Sub
A voir également:

2 réponses

lermite222 Messages postés 9042 Statut Contributeur 1 191
 
Bonjour,
Tu ne peu pas imbrigué 2 With, VBA ne s'y retrouverrait pas.
A+
0
clara95 Messages postés 9 Statut Membre
 
ah ok je ne savais pas. Pourquoi faire compliquer quand on peut faire simple!!! merci pour l'info
0
lermite222 Messages postés 9042 Statut Contributeur 1 191
 
Mais tu peu régler ca avec...
Sub MiseEnPagedelafeuille() 

With AvtiveSheets.PageSetup 
.Orientation = xLandscape 
.LeftMargin = Application.InchesToPoints(0.5) 
.RightMargin = Application.InchesToPoints(0.5) 
.TopMargin = Application.InchesToPoints(0.5) 
.BottomMargin = Application.InchesToPoints(0.5) 
.LeftHeader = "" 
.CenterHeader = "&A" 
.RightHeader = "" 
.LeftFooter = "" 
.CenterFooter = "Page & P" 
.RightFooter = "" 
End With 
AvtiveSheets.Colums.EntireColumn.AutoFit 
AvtiveSheets.Rows.EntireRow.AutoFit 

ActiveWindow.SelectSheets.PrintPreview 
End Sub

A+
0