string comparison on foundfiles object

T

Tony_at_work

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
 
J

Jay Freedman

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
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
T

Tony_at_work via OfficeKB.com

Jay,

Many thanks for your assistance.

Tony

Jay said:
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
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
[quoted text clipped - 13 lines]
 

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