XL pour MAC Définir 2 zones d'impression pour 2 pages d'un même document (pdf)

pierrealti

XLDnaute Nouveau
Bonjour à tous,
J'ai beaucoup cherché mais pas trouvé.
Une macro me permet d'exporter 1 pdf par signet
VB:
Sub SaveSignetsPDF() 'Pierre Octobre 2018
    Dim FileName$, FolderName$, Folderstring$, FilePathName$, LeParcours$
    'Set the Orientation of the sheet, seems to default to xlPortait
    'if we not use this code line. This is a bug in Mac Excel 2016
    ActiveSheet.PageSetup.Orientation = ActiveSheet.PageSetup.Orientation
    
Dim WS_Count As Integer
         Dim I As Integer

         ' Set WS_Count equal to the number of worksheets in the active
         ' workbook.
         WS_Count = ActiveWorkbook.Worksheets.Count

         ' Begin the loop.
         For I = 1 To WS_Count
            'Chemin = "/Users/lti2/Desktop/Evaluation/" '<-- à adapter
            Stagiaire = Worksheets(I).Range("B2").Value
            NO = Worksheets(I).Name
            NomFormation = "Evaluation - "
    

   FileName = NomFormation & Stagiaire & ".pdf"
   'FileName = Format(Date, "yyyymmdd") & " " & Stagiaire & ".pdf"
 
    'Make folder in the Office folder if it not exists and create the path/file name
    FolderName = "PDFSaveFolder"
    Folderstring = CreateFolderinMacOffice2016(NameFolder:=FolderName)
    FilePathName = Folderstring & Application.PathSeparator & FileName
    'Réduire les marges à 0,2
    
   Worksheets(I).PageSetup.PrintArea = "$A$1:$H$52"
   Worksheets(I).Rows(17).PageBreak = xlPageBreakManual
    Application.PrintCommunication = False
    
    With Worksheets(I).PageSetup
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.7)
        .BottomMargin = Application.InchesToPoints(0.7)
        .Orientation = xlPortrait
        '.Orientation = xlLandscape
        '.Zoom = False
        '.FitToPagesTall = 2
       '.FitToPagesWide = 1
    End With
    Application.PrintCommunication = True
    
    'Faire une sélection avant impression
    'Range("A1:I35").Select
    
    'ExportAsFixedFormat is not working correct in Mac Excel 2016, for example:
    'expression A variable that represents a Workbook, Sheet, Chart, or Range object
    'is not working if you change ActiveWorkbook, it always save the activesheet.
    'Also the parameters are not working like in Win Excel.
    Worksheets(I).ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
    FilePathName, Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False
      Next I
    MsgBox "Votre fichier PDF à été enregistré sous : " & FilePathName, , "Chemin de votre Fichier PDF"
End Sub
Le pdf généré est toujours sur 2 pages.
Tout fonctionne très bien mais je souhaiterais que la page 1 intègre les plages A1:H17 et la page 2 A18:H52
Les signets sont tous identiques, pas de conditions, c'est toujours les mêmes plages.
Petite précision, je travaille sur Excel Mac 2016.
Un grand merci par avance pour votre aide.
 

Discussions similaires

Statistiques des forums

Discussions
312 087
Messages
2 085 198
Membres
102 815
dernier inscrit
Henridic