Wikipedia

Search results

Sunday 22 December 2013

Create Hyperlink with all Files of a Folder...



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


regards,
Vikas Verma


No comments:

Post a Comment