Sub pdf()
Dim Folder As FileDialog, FicName As String, Path As String
' Petit message annoncant la macro
If MsgBox("Do you want to convert in pdf file ?", vbYesNo, "Do you want to convert in pdf file ?") = vbNo Then Exit Sub
' Boite de dialogue office pour le choix du dossier
Set Folder = Application.FileDialog(msoFileDialogFolderPicker)
With Folder
.AllowMultiSelect = False
.InitialFileName = "Desktop"
.Title = "Select a Folder"
If .Show = -1 Then Path = .SelectedItems(1) & "\" Else Exit Sub
End With
' Construire le nom complet du fichier avec chemin d'accès
FicName = Path & "\" & ActiveWorkbook.Name & "Repair"
On Error Resume Next
Sheets("Repair").ExportAsFixedFormat Type:=xlTypePDF, Filename:=FicName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
' Si aucune erreur ne c'est produite
If Err.Number = 0 Then
MsgBox ("Conversion completed")
'ouvrir le dossier de destination pour vérifier le bon déroulement de la sauvegarde
Shell "Explorer.exe " & Path, 3
Else ' sinon
MsgBox "Une erreur c'est produite" & vbCr _
& Err.Number & "-" & Err.Description, vbCritical, "OUPS ...."
End If
On Error GoTo 0
End Sub