Sub OpenFolderAndListFiles() Dim objShell As Object Set objShell =…
- User
Sub OpenFolderAndListFiles() Dim objShell As Object Set objShell = CreateObject("Shell.Application") ' Display folder selection dialog box and get selected folder path On Error Resume Next strPath = objShell.BrowseForFolder(0, "Select a Folder", 1).Self.Path If Err.Number <> 0 Then Exit Sub On Error GoTo 0 ' Check if folder was selected and display message box with list of files in the folder If strPath <> "" And strPath <> "False" Then Set objFSO = CreateObject("Scripting.FileSystemObject") ' Get reference to root folder object Set objFolder = objFSO.GetFolder(strPath) ' Define font size and style for displaying the folder name in bold strFontSize = "14" strStyle = "Bold" ' Display list of files and subfolders in selected folder with folder names in bold and larger font For Each objSubFolder In objFolder.SubFolders Debug.Print vbTab & objSubFolder.Name, strStyle, strFontSize For Each objFile In objSubFolder.Files ' Display file name as a clickable link to open the file in its default application strLinkText = objFile.Name Debug.Print vbTab & vbTab & "<a href=""" & objFile.Path & """>" & strLinkText & "" Next For Each subObj In objSubFolder.SubFolders ' Display list of files and subfolders in selected folder with folder names in bold and larger font Debug.Print vbTab & vbTab & subObj.Name, strStyle, strFontSize For Each fileInSubfolder In subObj.Files ' Display file name as a clickable link to open the file in its default application strLinkText = fileInSubfolder.Name Debug.Print vbTab & vbTab & vbTab & "<a href=""" & fileInSubfolder.Path & """>" & strLinkText & "" Next Next Next Else MsgBox "No folder was selected." End If End Sub what is wrong with this code ?
- Assistant
- User
list content in excel
- Assistant
- User
files are not clickable
- Assistant
- User
great but i want data ierahicaly , folders and subfolder vertical arajment
- Assistant