Skip to main content

Folder.SubFolders property

Table of contents
  1. Syntax
  2. Examples

Returns a Folders collection consisting of all folders contained in a specified folder, including those with Hidden and System file attributes set.



The object is always a Folder object.


The following code illustrates the use of the SubFolders property.

Sub ShowFolderList(folderspec)
    Dim fso As Object, f As Object, f1, fc As Object, msg As String
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder(folderspec)
    Set sf = f.SubFolders
    For Each f1 In sf
        msg = msg & f1.Name
        msg = msg & vbCrLf
    Debug.Print msg
End Sub

Run the following code in the Immediate Window to test this macro:



floder A
hidden floder

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>