Export PDF dans dossier racine

Bonjour,

j''utilise un code vba qui permet d'exporter 1 fichier PDF séparé par feuille.

Cela fonctionne correctement.

Actuellement il export les fichier PDF dans le dossier "Documents" du poste de travail.

Pourriez vous m'aider a indiquer le chemin des fichiers exportés dans e dossier racine du document excel.

Voici le code actuel :

Sub ExportFeuillesPDF()

Application.ScreenUpdating = False

Sheets("LOGO").Visible = True

Dim Sh As Worksheet

For Each Sh In ThisWorkbook.Sheets

Sh.Copy

ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

Sh.Name & ".pdf", Quality:=xlQualityStandard, _

IncludeDocProperties:=True, IgnorePrintAreas:=False, _

OpenAfterPublish:=False

ActiveWorkbook.Close False

Next Sh

Sheets("LOGO").Visible = False

MsgBox "PDF sont disponibles dans le dossier 'Documents' "

Application.ScreenUpdating = True

End Sub

MERCI PAR AVANCE

Bonjour,

Essaie ainsi :

Sub ExportFeuillesPDF()
Dim wb As Workbook, sh As Worksheet
Dim sPath As String, sFilename As String
    Application.ScreenUpdating = False
    Set wb = ThisWorkbook
    With wb
        sPath = .Path & Application.PathSeparator
        .Worksheets("LOGO").Visible = True
    End With
    For Each sh In ThisWorkbook.Sheets
        sFilename = sPath & sh.Name & ".pdf"
        sh.ExportAsFixedFormat _
                Type:=xlTypePDF, _
                Filename:=sFilename, _
                Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, _
                IgnorePrintAreas:=False, _
                OpenAfterPublish:=False
    Next sh
    wb.Worksheets("LOGO").Visible = False
    MsgBox "PDF sont disponibles dans le dossier 'Documents' "
End Sub

Merci, cela fonctionne.

COOL

Rechercher des sujets similaires à "export pdf dossier racine"