FileSearch does not work, XP SVP1, Office 2002

G

Guest

I was testing the following filesearch in Excel by creating 3 text files in
the C:\ directory. I keep getting There were no files found. I tried this
on another computer and it worked fine. I tried the code in access, same
result.

Sub filesearchtest()


With Application.FileSearch
.NewSearch
.LookIn = "C:\"
.SearchSubFolders = False
.Filename = "*.txt"
.MatchTextExactly = False
'.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If

End With

End Sub
 
R

Ron de Bruin

Hi wejones

Try it with

.Filename = ".txt"

If it is not working use Dir
If you want a example post back
 
M

Myrna Larson

FileSearch is problematic. It doesn't work for me, either; same program
versions that you are using.
 
G

Guest

Did not work. This seems to be a specific problem with Office 2002 on my
machine. I have uninstalled office, used the cleanup program and reinstalled
it. But I still have the same problem.
 
R

Ron de Bruin

Hi

I am running also Office 2002 and it is working for me, but there are problems with
Application.FileSearch

Like i said use Dir, this is always working

Sub test()
Dim txtcount As Long
Dim TheFile As String
Dim MyPath As String
MyPath = "C:\"
ChDir MyPath
TheFile = Dir("*.txt")
txtcount = 0
Do While TheFile <> ""
txtcount = txtcount + 1
TheFile = Dir
Loop
MsgBox txtcount
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