List of Folders

B

Bruce

Hi, Everyone

I need to get a list of all sub-folders in a particular folder and load their names into a temporary table or an array so that I can process data in them sequentially. Does anyone have code that will do this that they are willing to share

I already have the "browse" code written by Terry Kreft, which is great for selecting the starting folder. Just need some help taking it from there

Thanks
Bruce
 
D

Douglas J. Steele

This what you're looking for?

Sub ListFolders()
Dim strFolder As String
Dim strSubfolder As String

' NOTE: The terminating slash is critical!
strFolder = "C:\Program Files\"
strSubfolder = Dir$(strFolder, vbDirectory)
Do While Len(strSubfolder) > 0
' Ignore the current directory and the encompassing directory.
If strSubfolder <> "." And strSubfolder <> ".." Then
Debug.Print strSubfolder
End If
strSubfolder = Dir$()
Loop

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bruce said:
Hi, Everyone!

I need to get a list of all sub-folders in a particular folder and load
their names into a temporary table or an array so that I can process data in
them sequentially. Does anyone have code that will do this that they are
willing to share?
I already have the "browse" code written by Terry Kreft, which is great
for selecting the starting folder. Just need some help taking it from
there.
 
B

Bruce

Thanks, Doug! I'll give it a try
Bruc

----- Douglas J. Steele wrote: ----

This what you're looking for

Sub ListFolders(
Dim strFolder As Strin
Dim strSubfolder As Strin

' NOTE: The terminating slash is critical
strFolder = "C:\Program Files\
strSubfolder = Dir$(strFolder, vbDirectory
Do While Len(strSubfolder) >
' Ignore the current directory and the encompassing directory
If strSubfolder <> "." And strSubfolder <> ".." The
Debug.Print strSubfolde
End I
strSubfolder = Dir$(
Loo

End Su


--
Doug Steele, Microsoft Access MV
http://I.Am/DougSteel
(no e-mails, please!


Bruce said:
Hi, Everyone
their names into a temporary table or an array so that I can process data i
them sequentially. Does anyone have code that will do this that they ar
willing to sharefor selecting the starting folder. Just need some help taking it fro
there
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top