.FileSearch not finding files that exist

I

Ian Lauder

I have the following FileSearch test reproducable on a
brand new Dell laptop, running Windows XP Pro (with all
patches applies as of 10/17), and Office XP Pro (with all
patches applied as of 10/17).

There are about 50 Word documents with .doc file
extensions in the "c:\temp" folder.

The following code sample finds the folder, but
regardless of how I try and tweak the FileSearch
settings, it always returns 0 files found. Searching
the folder via the command prompt/desktop shows they
exist. Are there any known problems with the FileSearch
not returning results? This happens on a number of our
clients computers and works on some of ours, however now
with this new laptop all patched up, it is a reproducable
problem.

Note, this doesn't appear to be a coding problem as the
same code snippet on another of my machines also running
with a fully patched Office XP Pro and Windows XP Pro
does return results. There does appear to be a problem
with this feature somewhere as the problem crops up at
various client sites as well as one of our machines.

In Word, create the following macro and put some .doc
files in the c:\temp folder

<<<<<
Sub TestSearch()

Dim NumDestFiles As Integer
Dim fs As FileSearch
Dim SearchDir As String

SearchDir = "C:\TEMP"

Set fs = Application.FileSearch

NumDestFiles = 0

If (Dir(SearchDir, vbDirectory) <> "") Then
With fs
.NewSearch
.LookIn = SearchDir
.SearchSubFolders = False
.FileName = "*.doc"
.FileType = msoFileTypeAllFiles

RetVal = .Execute

NumDestFiles = .FoundFiles.Count

End With
End If


End Sub
 
I

Ian Lauder

Just an FYI. After further testing, adding a call to
FileExists on a document in the folder being searched
does return TRUE, so FileExists finds the
file "c:\temp\accept.doc" while the next statement for
the FileSearch is return 0 files found.

Also, no other software was installed after Office XP Pro
was installed and patched and after the most recent
Windows XP Pro patches were applied.
 
T

Tom Ogilvy

One thing you can try:
change
.FileName = "*.doc"

to
.FileName = ".doc"

I know it seems illogical, but the one without "*" is more robust.
 
R

RedPepper

Hi,

I have exactly the same problem working with Excel 2002 on Windows 2000
Professional. I tried all possibilities and always get 0 for
filesearch.execute. If somebody has a solution, it would be greatly
appreciated.

Thanks,

RP
 

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