Excel 2007 / application.filesearch no longer works

P

Pete Ross

Hello,

In 2007, the application.filesearch no longer works for my vba scripts, I'm
trying to find a work around, I figured out how to loop through files in a
given folder, but need help creating one more nested loop so that I can loop
through folders, then loop through the files in each folder, here is a sample
of what I have so far, any help would be greatly appreciated.

Dim sFolder As String
Dim Folder As Object
Dim file As Object
Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = "C:\temp"
'***I have multiple folders in temp, need to find code to loop thru each......
If sFolder <> "" Then
Set Folder = fso.GetFolder(sFolder)
For Each file In Folder.Files
MyFile = file
'**** do stuff to each file
Next file
End If
 

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