Macro PDF en A3

Bonjour à tous,

Je souhaite sortir un fichier Excel en PDF. Jusqu'ici tout va bien mais l'export se fait en A4 alors que mon fichier excel est en A3.

J'ai essayé de rajouter la ligne ActiveSheet.PageSetup.PaperSize = xlPaperA3 mais cela ne marche pas. Voici le détail de ma formule:

'Onglet RECAP Globale YTD - PDF

With Sheets("RECAP Globale YTD").Activate

Range("A1:N102").Select

ActiveSheet.PageSetup.PrintArea = "$A$1:$N$102"

ActiveSheet.PageSetup.PaperSize = xlPaperA3

ActiveSheet.PageSetup.CenterHorizontally = True

End With

nom = "RECAP Global YTD"

nom_dossier = Sheets("Paramètres").Cells(6, 2).Value

LeRep = "S:\XXX\XXX\" & nom_dossier

Sheets("RECAP Globale YTD").ExportAsFixedFormat Type:=xlTypePDF, Filename:=LeRep & " - " & nom & ".pdf"

Sauriez-vous me dire pourquoi le PDF ne sort pas en A3 automatiquement?

Merci d'avance pour votre aide.

Bonjour,

Pas sûr que votre paramétrage s'applique à la bonne feuille :

With Sheets("RECAP Globale YTD")
 .Range("A1:N102").Select
 .PageSetup.PrintArea = "$A$1:$N$102"
 .PageSetup.PaperSize = xlPaperA3
 .PageSetup.CenterHorizontally = True
End With

Bonjour,

Pourquoi un end with avant l'impression pdf ?

le code m'a l'air un peu dans le désordre non ?

Dim nom as string
Dim nom_dossier as string
Dim LeRep as string

nom = "RECAP Global YTD"
nom_dossier = Sheets("Paramètres").Cells(6, 2).Value
LeRep = "S:\XXX\XXX\" & nom_dossier

With Sheets("RECAP Globale YTD").Activate
Range("A1:N102").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$N$102"
ActiveSheet.PageSetup.CenterHorizontally = True
ActiveSheet.PageSetup.PaperSize = xlPaperA3
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=LeRep & " - " & nom & ".pdf"

end with

end sub

Rechercher des sujets similaires à "macro pdf"