title: Listing all folders in my directory visual basic
body: <p>I am trying to list all my folders from a drive in a directory onto an excel spreadsheet with a touch of a button. I made the button and assigned this macro... why won't it compile? The *** **** shows what they debugged. Said object folder was not an object. Please help!</p>
  
  <pre><code>Sub ListAllFile()
  
  Dim objFSO As Object
  Dim objFolder As Object
  Dim objFile As Object
  Dim ws As Worksheet
  
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set ws = Worksheets.Add
  
   'Get the folder object associated with the directory
  
  ***Set objFolder = fso.GetFolder("C:hello\EMILY")***
  ws.Cells(1, 1).Value = objFolder.Name
  
   'Loop through the Files collection
  For Each objFile In objFolder.Files
      ws.Cells(ws.UsedRange.Rows.Count + 1, 1).Value = objFile.Name
  Next
  
  
  End Sub
  </code></pre>