Sub OuvreFicWord()
Dim fso As Object, D As Object, Lettre As String, Wrd as Object
Const SN As Long = -793523017
Set fso = CreateObject("Scripting.Filesystemobject")
On Error GoTo ErrLecteur
For Each D In fso.drives
If D.SerialNumber = SN Then
Lettre = D.DriveLetter
Exit For
End If
Suite:
Next
On Error GoTo 0
If Lettre = "" Then
MsgBox "Clé non trouvée"
Else
'MsgBox "Chemin du fichier :" & Chr(10) & Lettre & ":\collegebis\exercices compétences 5ème\Electricité\Circuits électriques.docx"
End If
Set D = Nothing
Set fso = Nothing
Set Wrd = CreateObject("Word.Application")
Wrd.Visible = true
wrd.documents.open Lettre & ":collegebis\exercices compétences 5ème\Electricité\Circuits électriques.docx"
Set Wrd = Nothing
Exit Sub
ErrLecteur:
Resume Suite
End Sub