based this path:
"C:\Lavori_Vb6\COMUNI\STEMMI\"
how to retrieve the name of each subdir?
attached the structure
in my case are 20 subdir
get the name of sub dir
-
- PlatinumLounger
- Posts: 4351
- Joined: 26 Apr 2010, 17:36
get the name of sub dir
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78411
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: get the name of sub dir
Code: Select all
Sub ListSubfolders()
Dim strFolder As String
Dim strSubfolder As String
' Path must end in \
strFolder = "C:\Lavori_Vb6\COMUNI\STEMMI\"
strSubfolder = Dir(strFolder & "*.*", vbDirectory)
Do While strSubfolder <> ""
Select Case strSubfolder
Case ".", ".."
' Skip these
Case Else
Debug.Print strSubfolder
End Select
strSubfolder = Dir
Loop
End Sub
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 144
- Joined: 11 Jun 2012, 20:37
Re: get the name of sub dir
or:
Code: Select all
Sub GetSubFolderNames()
Set fso = CreateObject("Scripting.FileSystemObject")
For Each MySubFolder In fso.GetFolder("C:\Lavori_Vb6\COMUNI\STEMMI").SubFolders
Debug.Print MySubFolder.Name
Next MySubFolder
End Sub