Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Excel 97 Using the Dir function I have few problems with finding/listing files in Drives/Folders/Subfolders etc. providing that I know the path. How would I go about finding Folders in a Drive, Subfolders in a Folder etc.? Any help will be gratefully received. Regards, Don. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Don,
Google "File System Object" or "FSO". This ActiveX object will do exactly what you need. For example, this Excel code lists all of the folders immediately under the C:\ drive: Sub runFolderList() On Error Resume Next Dim rootFolder Dim subFolders Set fso = CreateObject("Scripting.FileSystemObject") Set rootFolder = fso.GetFolder("C:\") Set subFolders = rootFolder.subFolders For Each folder In subFolders Debug.Print "Folder: " & folder.Name Next Set subFolders = Nothing Set rootFolder = Nothing Set fso = Nothing End Sub Hope this helps, Stan Scott New York City "Don Lloyd" wrote in message ... Hi, Excel 97 Using the Dir function I have few problems with finding/listing files in Drives/Folders/Subfolders etc. providing that I know the path. How would I go about finding Folders in a Drive, Subfolders in a Folder etc.? Any help will be gratefully received. Regards, Don. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you Stan,
It worked a treat. Don "Stan Scott" wrote in message ... Don, Google "File System Object" or "FSO". This ActiveX object will do exactly what you need. For example, this Excel code lists all of the folders immediately under the C:\ drive: Sub runFolderList() On Error Resume Next Dim rootFolder Dim subFolders Set fso = CreateObject("Scripting.FileSystemObject") Set rootFolder = fso.GetFolder("C:\") Set subFolders = rootFolder.subFolders For Each folder In subFolders Debug.Print "Folder: " & folder.Name Next Set subFolders = Nothing Set rootFolder = Nothing Set fso = Nothing End Sub Hope this helps, Stan Scott New York City "Don Lloyd" wrote in message ... Hi, Excel 97 Using the Dir function I have few problems with finding/listing files in Drives/Folders/Subfolders etc. providing that I know the path. How would I go about finding Folders in a Drive, Subfolders in a Folder etc.? Any help will be gratefully received. Regards, Don. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Must have feature - Tab Folders | Excel Discussion (Misc queries) | |||
linking folders | Excel Discussion (Misc queries) | |||
Changing Folders! | Excel Worksheet Functions | |||
To create folders using VBA | Excel Discussion (Misc queries) | |||
Creating folders with VB | Excel Programming |