View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_2_] Leith Ross[_2_] is offline
external usenet poster
 
Posts: 128
Default "Listing Contents of Sub-Folders"

On Oct 28, 8:01 pm, Don wrote:
Here's a snippit of code (attached to a userform) that I use to list files
contained in a folder. This code only picks up files contained in the folder
selected and not in any sub-folders of that folder. What change(s) do I need
to make so that the code identifies files contained in sub-floders also?

If OptionButton1 Then
EXT = "*.MP3"
ElseIf OptionButton2 Then
EXT = "*.CDG"
ElseIf OptionButton3 Then
EXT = "*.ZIP"
ElseIf OptionButton4 Then
EXT = "*.*"
End If
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
ThePath = .SelectedItems(1) & "\"
End With
fname = Dir(ThePath & EXT)

TIA...Don


Hello Don,

All system file viewers show only the contents of the directory (last
folder in the path). None will identify specified file types in the
sub-folders. If you had only 2 or 3 sub-folders, you could create
another form with a ListBox for each sub-folder. If you are dealing
with an unknown number of sub-files then creating ListBoxes for each
sub-folder becomes problematic.

Sincerely,
Leith Ross