Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

File Search

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adriana Malamud - 09 Nov 2005 14:59 GMT
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!--

Signature

Adriana

Helmut Weber - 09 Nov 2005 16:38 GMT
Hi Adriana,

see (one line)
http://groups.google.de/group/microsoft.public.word.vba.general/browse_frm/threa
d/6ed158b2250e7827/60ff1818686098d9?lnk=st&q=FileSearch+group:microsoft.public.w
ord.vba*+author:Helmut+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.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Adriana Malamud - 09 Nov 2005 19:20 GMT
Thanks, that helped me a lot.
What do you mean by saying: processing the result of filesearch once more?
Thanks again
Signature

Adriana, Buenos Aires, Argentina

"Helmut Weber" escribió:

> Hi Adriana,
>
[quoted text clipped - 17 lines]
> Not to difficult, using the dir-function,
> or processing the result of filesearch once more.
Helmut Weber - 10 Nov 2005 08:25 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.