How to List All Files in a Folder and Create Hyperlinks to Each File

How to List All Files in a Folder and Create Hyperlinks to Each File



Below VBA Code:-

Sub Example1()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer


Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("C:\NitinVbaApp\Images\")
i = 1

For Each objFile In objFolder.Files
    'select cell
    Range(Cells(i + 1, 1), Cells(i + 1, 1)).Select
    'create hyperlink in selected cell
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
        objFile.Path, _
        TextToDisplay:=objFile.Name
    i = i + 1
Next objFile

End Sub

About Me

author Click here for Connect FB

Click here for Linkedin

Related Post No.

Powered by Blogger.

Contact Form

Name

Email *

Message *

Search This Blog

Recent Posts

Breaking

Popular Posts

Recent Posts

Trending Topic

Breaking

Related Post No.

Pages