Sub FileName1()
Dim I As Integer
Dim fl As File
Dim fldr As Folder
Dim sh As Worksheet
Dim fso As FileSystemObject
Dim Fpath As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
Fpath = .SelectedItems(1)
Range("A1") = "File Name"
End With
I = 2
Set fso = New FileSystemObject
Set fldr = fso.GetFolder(Fpath)
For Each fl In fldr.Files
First.Cells(I, 1) = fl.Name
If First.Cells(I, 1) = fl.Name Then
First.Cells(I, 1).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=fl.Path
End If
I = I + 1
Next fl
End Sub
Vikas Verma
No comments:
Post a Comment