Aide pour une mise en page avec VBA
clara95
Messages postés
9
Statut
Membre
-
lermite222 Messages postés 9042 Statut Contributeur -
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
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
Configuration: Windows Vista Internet Explorer 7.0
2 réponses
-
Bonjour,
Tu ne peu pas imbrigué 2 With, VBA ne s'y retrouverrait pas.
A+ -
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+