Results 1 to 12 of 12

Thread: VB - List all subfolders in a specific folder

Threaded View

  1. #1

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    VB - List all subfolders in a specific folder

    Add a reference to the "Microsoft Scripting Runtime":

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim strStartPath As String
    3.     strStartPath = "C:\" 'ENTER YOUR START FOLDER HERE
    4.     ListFolder strStartPath
    5. End Sub
    6.  
    7. Private Sub ListFolder(sFolderPath As String)
    8.     Dim FS As New FileSystemObject
    9.     Dim FSfolder As Folder
    10.     Dim subfolder As Folder
    11.     Dim i As Integer
    12.    
    13.     Set FSfolder = FS.GetFolder(sFolderPath)
    14.  
    15.     For Each subfolder In FSfolder.SubFolders
    16.         DoEvents
    17.         i = i + 1
    18.         Debug.Print subfolder
    19.     Next subfolder
    20.     Set FSfolder = Nothing
    21.     MsgBox "Total sub folders in " & sFolderPath & " : " & i
    22. End Sub
    Last edited by manavo11; May 13th, 2003 at 03:41 PM.


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width