FileSearch

S

Stephen

I can't get FileSearch to return a correct file search.
Application.FileSearch.FoundFiles.Count is always zero.

Does the Application.FileSearch no longer work in Excel
VB 2002?


Tx,

Stephen
 
G

Gord Dibben

Stephen

Perhaps your search criterion(a) is/are not correct.

This works for me.

Sub file_find()
Set fs = Application.FileSearch
With fs
.lookin = "e:\program files\microsoft office\exceldata"
.Filename = "*.xls"
'or "*searchstring*"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
Else
MsgBox "There were no files found."
End If
End With
End Sub

Gord Dibben Excel MVP
 
D

Dave Peterson

Does changing this:
..Filename = "*.xls"
to
..Filename = ".xls"

help.

By the way, there have been a few posts that say that .filesearch is flakey in
xl2002. It sometimes doesn't find all the files. Although, I've never seen it
miss all of them.
 
M

Myrna Larson

I have. :(

Dave Peterson said:
Does changing this:
.Filename = "*.xls"
to
.Filename = ".xls"

help.

By the way, there have been a few posts that say that .filesearch is flakey in
xl2002. It sometimes doesn't find all the files. Although, I've never seen it
miss all of them.
 
D

Dave Peterson

I clicked on that link that Norman Jones posted.

It brought back memories of a previous thread that may look familiar. <bg>
 

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