title: Get list of sub-directories in VBA
body: <ul>
  <li>I want to get a list of all sub-directories within a directory. </li>
  <li>If that works I want to expand it to a recursive function.</li>
  </ul>
  
  <p>However my initial approach to get the subdirs fails. It simply shows everything including files:</p>
  
  <pre><code>sDir = Dir(sPath, vbDirectory)
  Do Until LenB(sDir) = 0
      Debug.Print sDir
      sDir = Dir
  Loop
  </code></pre>
  
  <p>The list starts with '..' and several folders and ends with '.txt' files.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong><br>
  I should add that this must run in Word, not Excel (many functions are not available in Word) and it is Office 2010.</p>
  
  <hr>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>One can determine the type of the result using</p>
  
  <pre><code>iAtt = GetAttr(sPath &amp; sDir)
  If CBool(iAtt And vbDirectory) Then
     ...
  End If 
  </code></pre>
  
  <p>But that gave me new problems, so that I am now using a code based on <code>Scripting.FileSystemObject</code>.</p>