File Search

  • Thread starter Adriana Malamud
  • Start date
A

Adriana Malamud

I've updated from office 97, some users are working with office XP and many
others with office 2003, (all windows 2000), both groups have the same
problem with this part of code:
Set fs = Application.FileSearch
With fs
.LookIn = "C:\xxx"
.FileName = "es*.txt"
If .Execute() > 0 Then
nCant = .FoundFiles.Count
Else
mensaje = MsgBox("NO Document found", vbExclamation)
GoTo Fin:
End If
End With
The problem is that the File Search seams to ignore that what I'm trying to
find are files starting with "es" ("es*.txt") , but instead finds all the
..txt files in that folder.
Any idea? Thanks!--
 
H

Helmut Weber

Hi Adriana,

see (one line)
http://groups.google.de/group/micro...ut+author:Weber&rnum=1&hl=de#60ff1818686098d9

Unfortunately, there seem to be some posts missing.


Dim fs As Object
Set fs = Application.FileSearch
With fs
.LookIn = "C:\test"
.FileName = "es*.txt"
' compare to:
' .FileName = "es*.*"
.Execute
MsgBox .FoundFiles.Count
End With

I guess, you have to use a workaround.
Not to difficult, using the dir-function,
or processing the result of filesearch once more.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
A

Adriana Malamud

Thanks, that helped me a lot.
What do you mean by saying: processing the result of filesearch once more?
Thanks again
 
H

Helmut Weber

Hi Adriana,

as with "es*.*" you get all files which start with "es",
you might like to remove those ending not with ".txt"
from .foundfiles(), or writing all other names into a new array,
or use something like (pseudocode, untested):
for l = 1 to foundfiles.count
if right(.foundfiles(l), 4) = ".txt" then
' whatever
endif
next

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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