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
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

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
 

Watch MrExcel Video

Forum statistics

Threads
1,114,415
Messages
5,547,808
Members
410,813
Latest member
Vhinzvirgo
Top