foundfiles bad result

T

tonto96

Hallo newsgroup,
i have a problem with the application.filesearch.foundfiles command.
sometimes i get a wrong result. instead of two files (which are in the
directory) i get zero or one as result.
if i use instead of
.Filename = "*.xls"
.Filename = "*.*"
it takes a lot of time (nearly 30 seconds before the ".execute"
command comes to an end), but the result is ok. if i run the orign
code afterwards the result for .Filename = "*.xls" is correct too.

Here is the code that provokes wrong results:

With fs
.NewSearch
.LookIn = xlsPath
.SearchSubFolders = False
.Filename = "*.xls"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
For j = 1 To .FoundFiles.Count
...

Any idea
Thanks in advance
Lars
 
J

Jim Cone

Lars,
FileSearch has a bad reputation. You have found out why.
The Dir function can replace it as long as you don't need to
search thru sub-folders...
'--

'Adds file names from the directory path into an array
Function LoadThemUp(ByRef sFileArray() As String, ByRef sDir As String) As Byte
Dim sFile As String
Dim x As Long
ReDim sFileArray(1 To 500) 'arbitrary

'All the types you want to see
sFile = Dir(sDir, vbNormal + vbSystem + vbHidden)

Do While LenB(sFile)
x = x + 1
sFileArray(x) = sFile
sFile = Dir()
Loop
ReDim Preserve sFileArray(1 To x)
End Function
--
Jim Cone
Portland, Oregon USA



"tonto96"
<[email protected]>
wrote in message
Hello newsgroup,
i have a problem with the application.filesearch.foundfiles command.
sometimes i get a wrong result. instead of two files (which are in the
directory) i get zero or one as result.
if i use instead of
.Filename = "*.xls"
.Filename = "*.*"
it takes a lot of time (nearly 30 seconds before the ".execute"
command comes to an end), but the result is ok. if i run the orign
code afterwards the result for .Filename = "*.xls" is correct too.
Here is the code that provokes wrong results:

With fs
.NewSearch
.LookIn = xlsPath
.SearchSubFolders = False
.Filename = "*.xls"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
For j = 1 To .FoundFiles.Count
...
Any idea
Thanks in advance
Lars
 

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