I have this module that find all folders and files under the selected folder. The list of files path is generated in the excel sheet from the column B row 11 to infinity. I am trying to add a condition that changes column into an hyperlink for row 11 to infinity in column c. The aim is to be able to click on the cell with the path link to open the file. Greatly appreciate your expertise. The module is as follow:
Dim iRow
Sub ListFiles()
iRow = 11
Call ListMyFiles(Range("C7"), Range("C8"))
End Sub
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set Mysource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
For Each myFile In Mysource.Files
iCol = 2
Cells(iRow, iCol).Value = myFile.Path
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Name
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Size
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.DateLastModified
iRow = iRow + 1
Next
If IncludeSubfolders Then
For Each mySubFolder In Mysource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
End If
End Sub
Dim iRow
Sub ListFiles()
iRow = 11
Call ListMyFiles(Range("C7"), Range("C8"))
End Sub
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set Mysource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
For Each myFile In Mysource.Files
iCol = 2
Cells(iRow, iCol).Value = myFile.Path
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Name
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Size
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.DateLastModified
iRow = iRow + 1
Next
If IncludeSubfolders Then
For Each mySubFolder In Mysource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
End If
End Sub