Using Dir function to find folders

T

T_o_n_y

Can someone provide me with a working code snippet to find all folders in a
directory on a Mac? I'm running Excel 2004 on a mac, and know that I need to
use something like

FolderName = Dir(Input_Dir, MacID("TEXT"))

but something other than "TEXT" needs to go there. Can someone tell me what
the resource type is that I need to use to specify a folder?

Actually, I want to find the names of all sub folders within a folder so I
think I need to call it as above and then call

FolderName = Dir("", MacID("TEXT"))

or something like that for subsequent calls.

Thanks!
 
T

T_o_n_y

I found a way to do it without MacID. Here's what worked for me:

On Error Resume Next
subDir(1) = Dir(pathTbox, vbDirectory)
On Error GoTo 0
If subDir(1) = "" Then
MsgBox "No sub directories were found in " & pathTbox
Exit Sub
End If
j = 1
While subDir(j) <> ""
On Error Resume Next
j = j + 1
subDir(j) = Dir()
On Error GoTo 0
Wend
j = j - 1
msg = ""
For i = 1 To j
msg = msg & subDir(i) & vbCr
Next i
MsgBox "The " & j & " sub directories found were " & msg
Stop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top