ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Application.FileSearch (https://www.excelbanter.com/excel-programming/293518-vba-application-filesearch.html)

Roger Frye

VBA Application.FileSearch
 
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


All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com