Problems with appilcation.filesearch

J

Jan Kronsell

I have the following code:

Set fs = Application.FileSearch
With fs
.LookIn = "C:\test"
.Filename = "*.xls"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Workbooks.Open Filename:=.FoundFiles(i)
Sheets(1).Range("a1").Value = 10
ActiveWorkbook.Save
ActiveWorkbook.Close
Next i
Else
MsgBox "There were no files found."
End If
End With

One one pc it works allright, but on another i does not. One thje not
working one I get

Runtime error '1004'
Method 'Filesearch' of object '_application' failed

Both runs Win XP and Excel XP and both has the same refrences set.

Does anyone know, what could be the problem?

Jan
 

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