Application.Filesearch

OnTheBeach

New Member
Joined
Sep 15, 2006
Messages
1
Bit of a problem with application.filesearch.

Dim fs As FileSearch
....
Set fs = Application.FileSearch
fs.FileName = "*.*"
fs.SearchSubFolders = True
fs.NewSearch
fs.LookIn = "C:\Program files\Symantec\Act"
fs.Execute

jj = fs.FoundFiles.Count

For ii = 1 To jj
ff = fs.FoundFiles(ii)
Next ii

When I hit fs.filename = "*.*" (or any other string for that matter) I get a runtime error 5 invalid procedure call or argument.

The other properties works (i.e. newsearch etc - just this one.. Did a search thru object browser and it is there like all the other objects.

BTW - using Excel 97 on ME
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi, welcome to the board!

First off, I would put NewSearch first, but why not just use With? Also you don't do anything with the filenames it finds you just constantly overwrite the variable ff, what are you trying to do exactly?

Code:
Sub test2()
Dim ii As Long
With Application.FileSearch
    .NewSearch
    .Filename = "*.*"
    .SearchSubFolders = True
    .LookIn = "C:\Program files\Symantec\Act"
    If .Execute() > 0 Then
        For ii = 1 To .FoundFiles.Count
            MsgBox .FoundFiles(ii)
        Next ii
    End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,005
Messages
6,122,661
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top