XL 2016 Enregistrer un onglet en pdf avec nom et chemin dans cellule

christ77000

XLDnaute Occasionnel
Bonsoir à tous, je bloque sur cette macro. Cette macro enregistre l'onglet Excel au format PDF avec le nom en K13 et le chemin en A83. J'ai essayer avec ma petite connaissance du VBA de sortir une macro mais sans résultat. Pourriez vous svp m'aider, merci à vous.

Mon code d'origine qui fonctionne bien avec le nom mais pas de chemin prédéfini.
Code:
Sub Importer_pdf()
'
' Macro1 Macro
'

'
    Range("A1:E81").Select
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        ThisWorkbook.Path & "\" & Range("K13").Value & ".pdf", Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
    Range("A6:B6").Select
End Sub

Et ma tentative de modification.

VB:
Sub Importer_pdf()
'
' Macro1 Macro
'
Application.ScreenUpdating = False '---cacher les actions de la macro---
Dim Path As String, Nom As String

Application.DisplayAlerts = False
Path = Range("A83").Value
Nom = Range("K13").Value & ".pdf"

If Dir(Path & Nom) <> "" Then
    Else
'
    Range("A1:E81").Select
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        Path & Nom & , Quality:=
        xlQualityStandard , IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
    Range("A6:B6").Select
End Sub
 

christ77000

XLDnaute Occasionnel
Bonjour et merci, la nuit porte conseil. J'ai modifier mon chemin réseau, corrigé la coupure du code et mit le End If qui manquait. Bonne journée à tous :)

VB:
Sub Exporter_pdf()
'
' Macro1 Macro
'
Application.ScreenUpdating = False '---cacher les actions de la macro---
Dim Path As String, Nom As String

Application.DisplayAlerts = False
Path = Range("A85").Value
Nom = Range("K13").Value & ".pdf"

If Dir(Path & Nom) <> "" Then
    Else
'
    Range("A1:E81").Select
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        Path & "\" & Nom, Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
        End If
    Range("A6:B6").Select
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
311 720
Messages
2 081 902
Membres
101 834
dernier inscrit
Jeremy06510