1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Sub searchfilesandcreatehyperlink()
Dim Current_Region As Range
Dim Column_Number As Integer
Dim Line_Number As Integer
Dim k As Integer
Dim j As Integer
Line_Number = ActiveCell.CurrentRegion.Rows.Count
Column_Number = ActiveCell.CurrentRegion.Columns.Count
Set Current_Region = ActiveCell.CurrentRegion
Dim oFS As Office.FileSearch
Dim i As Integer
Set oFS = Application.FileSearch
With oFS
'for each cell in ActiveCell.CurrentRegion, créer l'hyperlink si le fichier existe
.NewSearch
.FileType = msoFileTypeAllFiles
.Filename = ActiveCell
.LookIn = "C:\Documents and Settings\R3282183\Desktop"
.Execute
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Sheets(1).Hyperlinks.Add anchor:=Cells(k, j), _
Address:=.FoundFiles(i), SubAddress:=""
Next i
End With
End Sub |
Partager