Lien Hypertexte
o
Bonjour à tous,
Voici une macro qui fonctionne, on recherche le nom écrit ds la colonne 6 si il est pressent dans le dossier lui ajout le lien strpath+nom colonne 6+extension (.gif)
'Chemin du dossier contenant le fichier
strPath = ThisWorkbook.Path & "\01-GAMME\313\"
'Rechercher dans le chemin déclarer les fichiers .gif correspondant au nom de la colonne 6
If Dir(strPath & Cells(i, 6).Text & ".gif") <> "" Then
'Si nom trouver dans le dossier lui affecter le lien
F.Hyperlinks.Add Anchor:=F.Cells(i, 6), Address:=strPath & F.Cells(i, 6) & ".gif", TextToDisplay:=F.Cells(i, 6).Value
Sauf que maintenant dans se même dossier je peux avoir 2 extensions différentes ".gif" ou ".xlsx"
je voudrai affecter en automatique extension qui correspond au fichier qui se trouve dans le dossier
'Chemin du dossier contenant le fichier
strPath = ThisWorkbook.Path & "\01-GAMME\313\"
'Rechercher dans le chemin déclarer les fichiers .gif ou .XLSX correspondant au nom de la colonne 6
If Dir(strPath & Cells(i, 6).Text & ".gif") <> "" or Dir(strPath & Cells(i, 6).Text & ".xlsx") <> "" Then
'Si nom trouver dans le dossier lui affecter le lien
F.Hyperlinks.Add Anchor:=F.Cells(i, 6), Address:=strPath & F.Cells(i, 6) & ".gif", TextToDisplay:=F.Cells(i, 6).Value 'je n'arrive pas a rattacher la bonne extension.
merci pour votre aide
Andre13Membre impliqué
- Messages
- 2'415
- Excel
- 2019
- Inscrit
- 13/07/2017
- Emploi
- Formateur, animateur,tech.informatique
Bonjour
as tu essayé comme ceci simplement (pas testé)
' ---
If Dir(strPath & Cells(i, 6).Text & ".gif" Or ".xlsx") <> "" Then
''---
lui, j'ai un doute ci-dessous
'------
F.Hyperlinks.Add Anchor:=F.Cells(i, 6), Address:=strPath & F.Cells(i, 6) & ".gif" or ".xlsx", TextToDisplay:=F.Cells(i, 6).Value
'--------
EDIT : je sèche pour le second
crdlt,
André
o
If Dir(strPath & Cells(i, 6).Text & ".gif") <> "" or Dir(strPath & Cells(i, 6).Text & ".xlsx") <> "" Then
cette fonctionne très bien ou j'ai un problème c’est sur cette ligne :
F.Hyperlinks.Add Anchor:=F.Cells(i, 6), Address:=strPath & F.Cells(i, 6) & ".gif", TextToDisplay:=F.Cells(i, 6).Value
je voudrais ajouter le ".xlsx" en plus, en fonction de l'extension du fichier trouver dans le dossier