Afficher le ou les fichiers liés à un nom dans un Combobox

Legendre

XLDnaute Nouveau
Bonjour
Je souhaite afficher un fichier .doc ou .docx ou .pdf lié au nom du Combobox
Je précise que le nom du ou des fichiers liés porte le même nom que celui du ComboBox
Mon code est le suivant :
----------------------------------------------------------------------------------------------------------------------------------------
Private Sub CommandButton25_Click()
'Ouvrir le fichier avec extension.docx correspondant au nom du materiel "ComboBox1"
If ActiveWorkbook.Name <> ThisWorkbook.Name Then ThisWorkbook.Activate
Dim NomFic As String, ArgDir As String
Dim Nom As String
Rep = Workbooks(ActiveWorkbook.Name).Path & "\Files\"
ArgDir = Rep & ComboBox1.Value & ".docx"
NomFic = Dir(ArgDir)
If NomFic <> "" Then
ThisWorkbook.FollowHyperlink Rep & NomFic
Else
MsgBox "Il n'existe pas de fichier au format word (.docx) associé au matériel :" & vbLf & ArgDir, vbCritical, Me.Caption
End If

End Sub
-------------------------------------------------------------------------------------------------------------------------------------------
Comment puis-je modifié mon code pour afficher les fichiers avec les trois formats (docx .doc et .pdf) ?
Dois-je faire trois instructions séparées correspondant chacune à un type des trois formats (pdf; docx; doc) ?
Merci
 
Dernière édition:

Discussions similaires