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

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+

job75

XLDnaute Barbatruc
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+
 

Discussions similaires

Réponses
2
Affichages
252

Membres actuellement en ligne

Statistiques des forums

Discussions
311 725
Messages
2 081 941
Membres
101 847
dernier inscrit
Djigbenou