T
T. Jenkins
This is my first time developing/editing macros since switching to Office
2007, so I'm wondering if I have a setting wrong someplace.
I'm trying to run a routine I used in the past to list all files in a
particular folder in a worksheet. Because I was having trouble getting this
to run, I searched the Excel help, and found the sample code below, which I
used to test the basic filesearch functionality. Since I'm getting the same
error, it's clear that something is wrong.
The code below errors-out at the initial line, "With
Application.Filesearch." The error is as follows: Run-time error 445: Object
doesn't support this action." This is the same error I'm getting in my
earlier code.
Do I have something configured wrong here? I would tell you the specifics
about the version I'm using, but since MS no longer seems to have a Help,
About option, I can't find it. I just know its Office 2007.
Thanks for the help.
=========== sample code ===========
With Application.FileSearch
.NewSearch
.LookIn = "J:\My Documents\__Print"
.SearchSubFolders = True
.Filename = "run"
.TextOrProperty = "San*"
.MatchAllWordForms = True
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
2007, so I'm wondering if I have a setting wrong someplace.
I'm trying to run a routine I used in the past to list all files in a
particular folder in a worksheet. Because I was having trouble getting this
to run, I searched the Excel help, and found the sample code below, which I
used to test the basic filesearch functionality. Since I'm getting the same
error, it's clear that something is wrong.
The code below errors-out at the initial line, "With
Application.Filesearch." The error is as follows: Run-time error 445: Object
doesn't support this action." This is the same error I'm getting in my
earlier code.
Do I have something configured wrong here? I would tell you the specifics
about the version I'm using, but since MS no longer seems to have a Help,
About option, I can't find it. I just know its Office 2007.
Thanks for the help.
=========== sample code ===========
With Application.FileSearch
.NewSearch
.LookIn = "J:\My Documents\__Print"
.SearchSubFolders = True
.Filename = "run"
.TextOrProperty = "San*"
.MatchAllWordForms = True
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With