![]() |
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. |
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. |
All times are GMT +1. The time now is 12:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com