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 / December 2006

Tip: Looking for answers? Try searching our database.

string comparison on foundfiles object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony_at_work - 13 Dec 2006 15:47 GMT
Hi,

I have used a foundfiles object so that I can open all word documents within
a particular folder on a network drive.

I would like to now do a LIKE comparison on the files that have been found
against some string criteria as shown below :

If fs.FoundFiles(i) Like "*red*" Or "*call*" Or "*knock" Or "early" Then

This is a mismatch since the foundfiles(i) referes to a path and not a string.

Can someone tell me how to convert the path to a string ?

Many thanks,

Tony
Jay Freedman - 13 Dec 2006 19:44 GMT
Hi Tony,

The path in .FoundFiles(i) *is* a string (or, technically, a variant
containing the equivalent of a string). That isn't your problem.

The problem is that your syntax is trying to use the Or operator to
combine strings,

  "*red*" Or "*call*" Or "*knock" Or "early"

But that operator can accept only Boolean arguments. The correct
syntax, comparing the values of the Like operations, is

 If (fs.FoundFiles(i) Like "*red*") Or _
    (fs.FoundFiles(i) Like "*call*") Or _
    (fs.FoundFiles(i) Like "*knock") Or _
    (fs.FoundFiles(i) Like "early") Then

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Hi,
>
[quoted text clipped - 13 lines]
>
>Tony
Tony_at_work - 14 Dec 2006 13:24 GMT
Jay,

Many thanks for your assistance.

Tony

>Hi Tony,
>
[quoted text clipped - 26 lines]
>>
>>Tony
 
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.