To use Drive Letter as Input Path in File search

  • Thread starter Thread starter Susanthika
  • Start date Start date
S

Susanthika

Hi Guys,

I intend to use the FileSearch object to list files matching certai
criteria(eg file name & file size). The code displayed below works fin
so long as folders are specified as the input directory/path to search
However, whenever I provide a Drive letter such as "C:\" or "D:\" a
the inpu path, the code executes indefinitely without responding. Th
code has been displayed below.

Please suggest a way to use Drive letter as Input Path

With Application.FileSearch
.NewSearch
.LookIn = "D:\"
.SearchSubFolders = includeSubFolders
.Filename = searchKeyName
.FileType = msoFileTypeAllFiles
End With

Set ACell = ActiveCell

With Application.FileSearch
If .Execute >0 ..... <I>(The code goes into an indefinit
execution mode at this point) </I>


Thanks in advance,
Susanthik
 
FileSearch produces an invisible list of files called the "FoundFile
object". You are asking it to go through all files on your hard drive
so expect it to take a bit of time to do so.

To check speed, see how long your computer takes to do a similar fil
search.

I don't know what 'searchKeyName' means in your code
 
Hi Brian,
Thanks for your reply !

searchKeyName is the regular expression variable for the file name
like name*, name? etc.

When I execute the macro, I fails to respond and when the task i
viewed in Task Manager, it shows 'Not Responding'. One minute, fiv
minutes...10 minutes the code just keeps on running.

As you said it is because of the sheer volume of the files to b
scoured, cos for the same search in Windows File search, windows say
to refine the search as the output exceeds 10,000 files! and when ther
are a few files in a drive the macro works fine.

It seems that FileSearch object just falters for large scal
processing :-(

Is there any way to handle this limitation ?

(Btw I liked your signature thought. A cup of coffee indeed relieve
the mental burden with it's effervescence
 
Back
Top