FileSystemObject and Subfolders

G

Guest

I have a requirement to perform mass changes to the footers of .xls files.
Using the filesystemobect, i have managed to display the names of the folders
immediately subordinate to my main path. I would like to loop through all
fodlers. There are many levels. Pasting what i have written to date. Any
ideas?

Dim fso As New FileSystemObject
Dim fsoFolder As Folder
Dim fsoSubFolders As Folders
Dim fsoFile As Object

Dim strHomeFolder As String
Dim strFolderName As String

On Error GoTo btnXL_Click_Error

strHomeFolder = "C:\ASOX\SOX Testing\"

Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(strHomeFolder)

'loop through the subfolder collection, displaying folder names
For Each fsoFolder In fsoFolder.SubFolders
strFolderName = fsoFolder.Name
MsgBox strFolderName, vbInformation, "displaying folder names"
Next

On Error GoTo 0
Exit Sub

T.I.A.
 
J

John Nurick

See http://support.microsoft.com/kb/185601.

For a one-off job, however, I'd just go to the Windows command prompt
and use something like this to create a text file containing the full
paths of all the files that need to be modified:

DIR /B /S "D:\TopLevelFolder\*.xls" > %TEMP%\XLFiles.txt
 

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