To use Drive Letter as Input Path in File search

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
 
B

BrianB

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
 
S

Susanthika

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
 

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