[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Re: Problems with Application.FileSearch

Jim Rech

12/15/2006 5:18:00 PM

I ran your code repeatedly and each time it found the correct number of
files. That said, I have in the past had my own problems with FileSearch
not returning all the files I thought it should and I consider it to be
unreliable. I prefer the tried and true Dir method.

--
Jim
"kristinaol" <kristinaol@discussions.microsoft.com> wrote in message
news:30412CFC-4DF7-4165-8E85-556ECA2AE390@microsoft.com...
>I am trying to search for a bunch of files using Application.FileSearch.
> Sometimes it works, but mostly it doesn't. It is as if some variable is
> not
> cleared, that the result from an old search is still in memory, and no new
> search is performed when I try to run the script again. Does anyone have
> any
> ideas what is wrong?
>
> The code looks as follows:
> (Variables files and no_of_files are declared earlier)
>
> With Application.FileSearch
> .NewSearch
> .LookIn = Path
> .FileType = msoFileTypeExcelWorkbooks
> If .Execute() > 0 Then
> ReDim files(1 To .FoundFiles.Count)
> no_of_files = .FoundFiles.Count
> Else
> MsgBox "There were no files found."
> Exit Sub
> End If
> End With