XL 2013 PDF du 3ième onglet à la fin

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

jeromeN95

XLDnaute Impliqué
Bonsoir à tous,

j'souhaite crée un PDF à partir de l'onglet N°3 (Page de garde) jusqu'au dernier onglet (qui peut varier) :


VB:
   Sub PDFTEST()
    Dim sNomFichierPDF As String   'pour PDF
    Dim i As Integer 
Dim Ar(1) As String
 
  sNomFichierPDF = ThisWorkbook.Path & "\" 'chemin du fichier

   Ar = "3" ToCount
   
    Application.ScreenUpdating = False
Sheets(Ar).Select
                     
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & Range("Sommaire!B51").Value _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False
    Application.ScreenUpdating = True

    Sheets("Sommaire").Select
    Application.ScreenUpdating = True  'a supprimer?
   
Application.ScreenUpdating = True
    MsgBox "La création est terminée. !", vbInformation, "Planche"
End Sub


J'ai essayer aussi :
VB:
For i = 3 To Sheets.Count
Sheets(i).Select
Next i
sNomFichierPDF = ThisWorkbook.Path & "\" 'chemin du fichier
Sheets(i).Select 'selection des onglets...

Application.ScreenUpdating = False
    Sheets(i).Select

Mais ça ne fonctionne pas.
Aurais-je de l'aide svp ?
 
Solution
Bonsoir jeromeN95,
VB:
Sub PDF()
If Sheets.Count < 3 Then Exit Sub
Dim i%
Sheets(3).Select
For i = 3 To Sheets.Count
    Sheets(i).Select False 'sélection multiple
Next
ActiveSheet.ExportAsFixedFormat xlTypePDF, ThisWorkbook.Path & "\Bonsoir tout le monde"
Sheets(3).Select
End Sub
A+
Bonsoir jeromeN95,
VB:
Sub PDF()
If Sheets.Count < 3 Then Exit Sub
Dim i%
Sheets(3).Select
For i = 3 To Sheets.Count
    Sheets(i).Select False 'sélection multiple
Next
ActiveSheet.ExportAsFixedFormat xlTypePDF, ThisWorkbook.Path & "\Bonsoir tout le monde"
Sheets(3).Select
End Sub
A+
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

  • Question Question
Microsoft 365 Problème macro
Réponses
4
Affichages
245
Réponses
10
Affichages
547
Réponses
3
Affichages
672
Réponses
12
Affichages
703
  • Question Question
Microsoft 365 Code VBA
Réponses
10
Affichages
861
Retour