View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Extract folder names only

Michael,

I find the FileSystemObject much easier to use.
Below is slightly modified example from scripting help.
It adds a list to the active sheet of all folders contained in a specified
folder, including those with hidden and system file attributes set.
'------------------------------
Function ShowFolderList(folderspec)
Dim fso, f, f1, s, sf, n
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set sf = f.SubFolders
n = 1
For Each f1 In sf
s = f1.Name
Cells(n, 2).Value = s
n = n + 1
Next
ShowFolderList = s
End Function

'Run this to get things started.
'x must have a valid path
Sub MakeTheList()
Dim x As String
x = "C:\Documents and Settings\user\My Documents\Folder Name"
Call ShowFolderList(x)
End Sub
'-------------------------------

-OR-

You may want to try my free "List Files" Excel add-in.
It can create a list of folders meeting specified criteria.
Download it from here...
http://www.realezsites.com/bus/primitivesoftware


Regards,
Jim Cone
San Francisco, USA



"Michael Singmin" wrote in message ...
Hello group,
I am using Application.FileSearch
I don't want to extract any files, only the folder names.
I am assembling a fine art project with jpg images.
I have approximately 500 artists spread over 11 art movements.
Each artist has its own folder and the folder name displays his name,
birthdate and death date. I want to extract these folder names into a
worksheet.
Can FileSearch be used for my application ?
Thanks,
Michael Singmin