Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default FileSearch behaviour

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default FileSearch behaviour

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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default FileSearch behaviour

"Tom Ogilvy" wrote in message ...
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 problems all stemmed from having 'view hidden files & folders' checked.
The system folders had references to the contents of the stick etc.

Kevin


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filesearch in VB6 Colin Charman Excel Programming 3 June 18th 04 04:18 PM
FileSearch Stephen[_6_] Excel Programming 8 June 12th 04 11:14 PM
FileSearch using VBA Mark[_31_] Excel Programming 2 December 24th 03 05:49 PM
.FileSearch Randall[_3_] Excel Programming 4 November 26th 03 01:48 AM
FileSearch Problem Bin[_2_] Excel Programming 6 August 2nd 03 02:04 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"