Solved

What is the VBA to read subfolder names?

Posted on 2009-05-07
3
283 Views
Last Modified: 2013-11-27
Hi Experts,

What is the VBA to read subfolder names in the main folder?

Thanks
0
Comment
Question by:kosenrufu
  • 2
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
place this codes in a regular module
*add to your references microsoft scripting runtime

* to use the codes

call getfolders("c:\mymainfolder")

Sub GetFolders(sPath As String)

Dim fso As Scripting.FileSystemObject
Dim srcFolder As Scripting.Folder, sbFolder As Scripting.Folder
Dim fileItem As Scripting.File

Set fso = New Scripting.FileSystemObject
Set srcFolder = fso.GetFolder(sPath)

For Each sbFolder In srcFolder.SubFolders
   
    Debug.Print sbFolder.Name
   
Next

End Sub


0
 

Author Comment

by:kosenrufu
Comment Utility
capricorn1:

Getting the error, "User-defined type not found" in the line:

Dim fso As Scripting.FileSystemObject

Thanks
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
did you see this line above

*add to your references microsoft scripting runtime
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now