I have heard people say FileSearch is problematic, but never anything like
you describe. Here are some alternate approaches:
http://support.microsoft.com/kb/185476/EN-US/
How To Search Directories to Find or List Files
http://support.microsoft.com/kb/185601/EN-US/
HOW TO: Recursively Search Directories by Using FileSystemObject
--
Regards,
Tom Ogilvy
"kjs" wrote in message
...
FileSearch is producing duplicate results - listing the same file twice in
the FileSearch object. Additionally it's listing files outside the
specified
"C:\" drive. Some are found in the E drive, which is a flash stick. Even
when this stick has been pulled out. Even when it's been pulled out
and the computer restarted! I guess the search results are stored
somewhere, but am clueless about the duplicates.
Kevin.
The code used:
Public Sub SearchForXLsheets()
Dim oFound As FileSearch
Dim l As Long
Set oFound = Application.FileSearch
With oFound
.NewSearch
.LookIn = "C:\"
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
.Execute SortBy:=msoSortByFileName
If .FoundFiles.Count 0 Then
For l = 1 To .FoundFiles.Count
Cells(l, 1).Value = .FoundFiles(l)
Next l
End If
Columns("A:A").EntireColumn.AutoFit
End With
Set oFound = Nothing
End Sub