VBA Application.FileSearch

R

Roger Frye

This function works on some WinXP Pro, Excel 2002
installations, but not on others. The function is
adapted from the example in
Microsoft Knowledge Base Article - 210613

Function LocateFile(strFileName As String)
Dim vItem As Variant
With Application.FileSearch
.Filename = strFileName
.LookIn = "C:\"
.SearchSubFolders = True
.Execute
Debug.Print .FoundFiles.Count
For Each vItem In .FoundFiles
Debug.Print vItem
Next vItem
End With
Debug.Print "Done"
End Function

It should print out all locations of the file given as an
argument. Here is a printout from the Immediate window,
showing that on my machine, Application.FileSearch fails
to find any files:

LocateFile "AUTOEXEC.BAT"
0
Done

Why does this function fail on my machine, but work on
Win98, WinME, and WinXP Home machines? Is it a security
issue similar to the one reported in the Knowledge Base
about using JET to execute FileSearch?

Thanks for any responses.
-Roger
 

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