Add a reference to the "Microsoft Scripting Runtime":
VB Code:
Private Sub Command1_Click() Dim strStartPath As String strStartPath = "C:\" 'ENTER YOUR START FOLDER HERE ListFolder strStartPath End Sub Private Sub ListFolder(sFolderPath As String) Dim FS As New FileSystemObject Dim FSfolder As Folder Dim subfolder As Folder Dim i As Integer Set FSfolder = FS.GetFolder(sFolderPath) For Each subfolder In FSfolder.SubFolders DoEvents i = i + 1 Debug.Print subfolder Next subfolder Set FSfolder = Nothing MsgBox "Total sub folders in " & sFolderPath & " : " & i End Sub




Reply With Quote