Uses the Microsoft Scripting Runtime File System Object.
'---
Sub ListAllFilesInFolders()
'James Cone - Portland, Oregon USA
Dim strPath As String
Dim oFSO As Object
Dim oFile As Object
Dim oFolder As Object
Dim N As Long
strPath = "C:\Word Files\" '<<<ADJUST
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(strPath)
For Each oFile In oFolder.Files
'Do something here
N = N + 1
Next 'oFile
Call ListSubFolderFiles(oFolder, N)
Set oFSO = Nothing
Set oFile = Nothing
Set oFolder = Nothing
End Sub
'---
Function ListSubFolderFiles(ByRef oParentFolder As Object, ByRef lngR As Long)
'James Cone - Portland, Oregon USA
Dim oSubFolder As Object
Dim oFile As Object
For Each oSubFolder In oParentFolder.SubFolders
For Each oFile In oSubFolder.Files
'Do something here
lngR = lngR + 1
Next
ListSubFolderFiles oSubFolder, lngR
Next 'oSubFolder
End Function
'---
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(List Files XL add-in: finds and lists files/folders with hyperlinks)