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

Hi, everybody!

Does anyone know, how to get a list of folders with all
subfolders in Excel/VBA? I always get stuck when trying
to write a code for that.

Thanks in advance.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Get folders list

Eugene,

Set a reference (in VBA, Tools menu, References item) to
Microsoft Scripting Library and use code like the following:


Sub Start()
Dim FSO As Scripting.FileSystemObject
Dim TopFolder As Scripting.Folder
Set FSO = New Scripting.FileSystemObject
Set TopFolder = FSO.GetFolder("C:\Temp")
DoOneFolder TopFolder
End Sub

Sub DoOneFolder(F As Scripting.Folder)
Dim OneFolder As Scripting.Folder
'
' do something with F
Debug.Print F.Path

For Each OneFolder In F.SubFolders
DoOneFolder OneFolder
Next OneFolder
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Eugene" wrote in message
...
Hi, everybody!

Does anyone know, how to get a list of folders with all
subfolders in Excel/VBA? I always get stuck when trying
to write a code for that.

Thanks in advance.





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
Can I create folders in explorer from an excel list njmcr Excel Discussion (Misc queries) 5 February 28th 13 12:22 PM
Create folders from list vb/macro? Sherri Excel Discussion (Misc queries) 2 May 13th 09 07:40 PM
macro to list folders only, not files jat Excel Worksheet Functions 4 April 3rd 09 06:36 PM
List of folders in a certain directory woolyhedgehog Excel Discussion (Misc queries) 1 October 19th 05 04:28 PM
List folders to file SS Excel Discussion (Misc queries) 13 August 28th 05 07:44 PM


All times are GMT +1. The time now is 05:55 PM.

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

About Us

"It's about Microsoft Excel"