Hello,
I need some help in the following scenario.
I have Three Main Folders say X,Y,Z In "D" Drive and i want to
1. Select the main Folder using Option button....say X
2. Show the list of Subfolders in the above Selected Folder (i.e) X in a listbox.
3. Hyperlink the path of the selected subfolder from the listbox to a command button.
4. Click the command button to open the Selected subfolder
I am using the below macro to get the path list
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)
Next
End If
End Sub
I am herewith attaching the sample file.
Thanking you.
Regards,
Zaska
Bookmarks