Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Get list of subfolders

How do I create an array containing the list of all subfolders beneath a
specified folder (call it "C:\MyRoot"), and print that array as a list on
an excel spreadsheet?

Darren
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Get list of subfolders


Darren,

My Excel add-in "List Files" does that.
1. Folders and subFolders in a specified drive or folder can be listed.
or
2. Files in the specified folder, directory or drive can be listed.
Files in sub-folders are listed if requested.
Specific file types or names can be listed. (*.pdf, *.wav, etc)
Each file name, size, date and type go on the list.
Each file name on the list is hyperlinked.

All arranged in columns and rows that can be sorted.
Available - free - upon direct request.
Remove xxx from my email address

Regards,
Jim Cone
San Francisco, CA



"Darren Hill" wrote in
message news:opsm8er2qced89cl@omega...
How do I create an array containing the list of all subfolders beneath a
specified folder (call it "C:\MyRoot"), and print that array as a list on
an excel spreadsheet?
Darren

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Get list of subfolders

If you don't need the intermediate array, the example from HELP on DIR shows
the way. Here it is modified:

Sub ListSubs()
Dim MyPath As String, MyName As String
Dim rw As Long

rw = 1
MyPath = "c:\MyRoot\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName < "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName < "." And MyName < ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Cells(rw, 1).Value = MyName ' Display entry only if it
rw = rw + 1 ' represents a directory.
End If
End If
MyName = Dir ' Get next entry.
Loop
End Sub

--
Regards,
Tom Ogilvy


"Darren Hill" wrote in message
news:opsm8er2qced89cl@omega...
How do I create an array containing the list of all subfolders beneath a
specified folder (call it "C:\MyRoot"), and print that array as a list on
an excel spreadsheet?

Darren



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Get list of subfolders

Thanks, Tom, that will do perfectly - I don't need the array.

Darren

On Sun, 6 Mar 2005 15:25:45 -0500, Tom Ogilvy wrote:

If you don't need the intermediate array, the example from HELP on DIR
shows
the way. Here it is modified:

Sub ListSubs()
Dim MyPath As String, MyName As String
Dim rw As Long

rw = 1
MyPath = "c:\MyRoot\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName < "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName < "." And MyName < ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Cells(rw, 1).Value = MyName ' Display entry only if it
rw = rw + 1 ' represents a directory.
End If
End If
MyName = Dir ' Get next entry.
Loop
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help to list folders and subfolders tree in Excel or Word observer[_2_] Excel Discussion (Misc queries) 3 March 18th 09 03:42 PM
Auto look through subfolders grewpp Charts and Charting in Excel 1 February 14th 06 02:35 PM
Creating folders and subfolders from excel file list afaubert Excel Discussion (Misc queries) 4 November 8th 05 11:44 PM
Modify - look at files within subfolders Steph[_3_] Excel Programming 1 October 8th 04 06:51 PM
Create subfolders in a folder Myrna Rodriguez Excel Programming 2 July 15th 04 04:10 PM


All times are GMT +1. The time now is 04:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"