Obtain Sub-Folder Names with VBA?

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

Is it possible to obtain the names of all Sub-Folders for a specific parent
Folder?

Just 2 levels (1 Parent Folder) and several children folders.

We need the names of the sub-folders, not the names of the files in the
sub-folders.

Thanks for your help.
Brad
 
Lookup the Dir Function in the help file, specifically at the example it
illustrates exactly how to get a directory listing. You'll see it isn't hard!
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
Brad said:
Is it possible to obtain the names of all Sub-Folders for a specific
parent
Folder?

Just 2 levels (1 Parent Folder) and several children folders.

We need the names of the sub-folders, not the names of the files in the
sub-folders.

Thanks for your help.
Brad

Try this:

http://www.smccall.demon.co.uk/Downloads.htm#FsRecurse

Store the folder names as they are discovered, in the FolderFound event,
into a collection, table, etc.
 
Use Dir to list the files that have the vbDirectory attribute set, adn then
GetAttr() to test if it is a folder. The FileExists() and FolderExists()
functions here illustrate using those functions:
http://allenbrowne.com/func-11.html

This code lists files in a folder and its subfolders recursively:
http://allenbrowne.com/ser-59.html
Use that approach if you need to go down the tree further (i.e. the
sub-subfolders below that etc.)
 
Allen, Daniel, Stuart,

Thanks to all of you for the ideas/help.

You guys are great!

I have it working already with your help.

Brad
 

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

Back
Top