title: Excel VBA: Create list of subfolders and files within source folder
body: <p>I am using the following code to list all files in a host folder and it's sub folders. The code works great but, do you know how I can update the code to also list some the file attributes.</p>
  
  <pre><code>Sub file_list()
  
  Call ListFilesInFolder("W:\ISO 9001\INTEGRATED_PLANNING\", True)
  
  End Sub
  
  Sub ListFilesInFolder(ByVal SourceFolderName As String, ByVal IncludeSubfolders As Boolean)
  
  Dim FSO As Object
  Dim SourceFolder As Object
  Dim SubFolder As Object
  Dim FileItem As Object
  Dim r As Long
  Set FSO = CreateObject("Scripting.FileSystemObject")
  Set SourceFolder = FSO.getFolder(SourceFolderName)
  r = Range("A65536").End(xlUp).Row + 1
  For Each FileItem In SourceFolder.Files
  
    Cells(r, 1).Formula = FileItem.Name
    r = r + 1
    X = SourceFolder.Path
  Next FileItem
  If IncludeSubfolders Then
    For Each SubFolder In SourceFolder.Subfolders
      ListFilesInFolder SubFolder.Path, True
    Next SubFolder
  End If
  
  Set FileItem = Nothing
  Set SourceFolder = Nothing
  Set FSO = Nothing
  
  End Sub
  
  Function GetFileOwner(ByVal FilePath As String, ByVal FileName As String)
  
  Dim objFolder As Object
  Dim objFolderItem As Object
  Dim objShell As Object
  FileName = StrConv(FileName, vbUnicode)
  FilePath = StrConv(FilePath, vbUnicode)
  Set objShell = CreateObject("Shell.Application")
  Set objFolder = objShell.Namespace(StrConv(FilePath, vbFromUnicode))
  If Not objFolder Is Nothing Then
    Set objFolderItem = objFolder.ParseName(StrConv(FileName, vbFromUnicode))
  End If
  If Not objFolderItem Is Nothing Then
    GetFileOwner = objFolder.GetDetailsOf(objFolderItem, 8)
  Else
    GetFileOwner = ""
  End If
  Set objShell = Nothing
  Set objFolder = Nothing
  Set objFolderItem = Nothing
  
  End Function
  </code></pre>
  
  <p>What I would really like to see is;</p>
  
  <p>Column A = Host folder/subfolder</p>
  
  <p>Column B = File name</p>
  
  <p>Column C = hyperlink to file</p>
  
  <p>Is this possible?</p>
  
  <p>I do have a code that created hyperlinks but, I do not know how to add to the existing code.</p>
  
  <pre><code>Sub startIt()
  
    Dim FileSystem As Object
    Dim HostFolder As String
  
    HostFolder = "W:\ISO 9001\INTEGRATED_PLANNING\"
  
    Set FileSystem = CreateObject("Scripting.FileSystemObject")
    DoFolder FileSystem.GetFolder(HostFolder)
  
  End Sub
  
  Sub DoFolder(Folder)
  
    Dim SubFolder
    For Each SubFolder In Folder.Subfolders
      DoFolder SubFolder
    Next
  
    i = Cells(Rows.Count, 1).End(xlUp).Row + 1
    Dim File
    For Each File In Folder.Files
      ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 1), Address:= _
          File.Path, TextToDisplay:=File.Name
      i = i + 1
  
    Next
  
  End Sub
  </code></pre>