Solved

What is the VBA to read subfolder names?

Posted on 2009-05-07
3
289 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 24327235
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
ID: 24335220
capricorn1:

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

Dim fso As Scripting.FileSystemObject

Thanks
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24335261
did you see this line above

*add to your references microsoft scripting runtime
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

840 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