1 pièce(s) jointe(s)
Script fonctionne sur Version 2016 mais pas sous version 2021
Bonjour,
Ci-joint le code qui me permet de créér un fichier PDF à partir d'un état . Cela fonctionne bien sous Access 2016 , mais pas sous Access 2021.(Office 2021 Pro Plus)
Le message d'erreur "Erreur d'exécution :52 , Nom ou numéro de fichier incorrect" apparait .
Quelqu'un peut m'aider à trouver une solution svp. ?
Merci d'avance
Claude
Fonction :
Code:
1 2 3 4 5 6 7 8
| Function FileExist(FileFullPath As String) As Boolean
Dim value As Boolean
value = False
If Dir(FileFullPath) <> "" Then
value = True
End If
FileExist = value
End Function |
Pièce jointe 633093
Script :
Code:
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 27 28 29 30
| Private Sub Commande6_Click()
Dim fileName As String, fldrPath As String, filePath As String
Dim answer As Integer
fileName = "\carte RDV " & Me.REF_DOSSIER_B
'filename for PDF file*
fldrPath = "\\10.0.0.47\photos\" & Me.REF_DOSSIER_B
'folder path where pdf file will be saved *
filePath = fldrPath & "\" & fileName & ".pdf"
'check if file already exists
If FileExist(filePath) Then
answer = MsgBox(prompt:="Le fichier existe déjà : " & vbNewLine & filePath & vbNewLine & vbNewLine & _
"Remplacer le fichier ?", buttons:=vbYesNo, Title:="Existing PDF File")
If answer = vbNo Then Exit Sub
End If
On Error GoTo invalidFolderPath
DoCmd.OutputTo objecttype:=acOutputReport, objectName:="RPT_CRV", outputformat:=acFormatPDF, outputFile:=filePath
MsgBox prompt:="La carte RDV a été enregistré " & vbNewLine & filePath, buttons:=vbInformation, Title:="Report Exported as PDF"
Exit Sub
invalidFolderPath:
MsgBox prompt:="Error: Invalid folder path. Please update code." & fldrPath & fileName, buttons:=vbCritical
End Sub |