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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,126
Messages
5,857,522
Members
431,883
Latest member
Hien

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
Top