Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
so you don't repeat your code for the file processing part, you can make the
sub a recursive one... Sub ProcessFiles(strFolder As String) Dim oFSO As New FileSystemObject Dim oFolder As Folder Dim oSubFolder As Folder Dim oFile As File Set oFolder = oFSO.GetFolder(strFolder) 'process files in the starting folder For Each oFile In oFolder.Files 'do stuff Debug.Print oFile.Path Next oFile 'process sub folders For Each oSubFolder In oFolder.SubFolders ProcessFiles oSubFolder.Path Next oSubFolder End Sub you then would use it like this: Sub test() ProcessFiles "c:\mystuff" End Sub -- Hope that helps. Vergel Adriano "Vergel Adriano" wrote: Mike, Add a reference to the Windows Script Host Object Model and then try something like this: Sub ProcessFiles() Dim oFSO As New FileSystemObject Dim oFolder As Folder Dim oSubFolder As Folder Dim oFile As File Set oFolder = oFSO.GetFolder("C:\mystuff") 'process files in the starting folder For Each oFile In oFolder.Files 'do stuff Debug.Print oFile.Path Next oFile 'process files in sub folders For Each oSubFolder In oFolder.SubFolders For Each oFile In oSubFolder.Files 'do stuff Debug.Print oFile.Path Next oFile Next oSubFolder End Sub -- Hope that helps. Vergel Adriano "Mike H." wrote: I need to look at all files within a directory and I need to "climb" down sub-directories within those directories. For example: FileDir="C:\mystuff" I am using this loop: FName = Dir(FileDir) Do Until FName = "" do stuff Loop But if there is a folder "c:\mystuff\subdir\" I need to look there too. How do I determine sub-directories (folders) within folders? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Creating Directories | Excel Programming | |||
sub directories again | Excel Programming | |||
sub directories again | Excel Programming | |||
sub directories | Excel Programming | |||
Directories | Excel Programming |