Option Explicit
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Function OuvrirDocument(strChemin As String)
'Déclaration des variables
Dim strErreur As String
Select Case ShellExecute(0, "open", strChemin, vbNullString, vbNullString, 1)
Case 2: strErreur = "Fichier non trouvé."
Case 3: strErreur = "Chemin non trouvé."
End Select
If strErreur <> "" Then
MsgBox strErreur, vbCritical, "Erreur"
End If
End Function
Sub OpenFile(Nomfichier As String)
Dim X
Dim strFilePath As String
strFilePath = Application.CurrentProject.Path & "\Fichiers Joints\" & Nomfichier
X = OuvrirDocument(strFilePath)
End Sub