filesearch frustration

J

jason

sub A()
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\MY_USERNAME\Desktop"
.Filename = "*.xls"

MsgBox .FoundFiles.Count
End With
end sub


this keeps giving me a "0" but there is indeed a .xls on my desktop.
any help would save my from throwing my computer (not really), but any
help would be great.
thank you.
 
R

RonaldoOneNil

I find that FileSearch is very intermittent in whether it works or not. I use
the following instead.

sub A()
Dim strLookIn, fName as String
Dim intFound as Integer
strLookIn = "C:\Documents and Settings\MY_USERNAME\Desktop\"
intFound = 0
fName = Dir$(strLookIn & "*.xls")
Do While fName <> ""
intFound = intFound + 1
fName = Dir$
Loop
MsgBox intFound
End Sub
 

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