Il est possible de remplacer .Range("F20").Value par la fonction Now qui renvoie la date actuelle
l'erreur est dans le nom du dossier contenant des caractères illisibles
Const SubPath As String = "\ÇáÇÑÔíÝ\"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Sub t()
Const SubPath As String = "\archives\"
' // On prends en compte la feuille "certification" changer si nécessaire
With Feuil1
Dim CurrentPath As String
CurrentPath = .Parent.Path
Dim FullPath As String
FullPath = CurrentPath & SubPath
Dim FileName As String
FileName = "attestation " & .Range("C6").Value & " " _
& Format(.Range("F20").Value, "dd-mm-yyyy")
If Dir(FullPath, vbDirectory) = vbNullString Then MkDir (FullPath)
Dim FullName As String
FullName = FullPath & FileName & ".pdf"
' // Faire CTRL+G dans l'environnement VBE pour faire apparaitre la fenêtre d'exécution
Debug.Print "Le chemin d'enregistrement est : " & FullName
.ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullName
End With
End Sub |
Partager