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 / Mailmerge and Fax / October 2004

Tip: Looking for answers? Try searching our database.

Using COMPARE Function with Multiple Wildcards

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JASon - 13 Oct 2004 17:09 GMT
I've figured out how to use the COMPARE functionality in a Word merge:

{ COMPARE "{ MERGEFIELD Name }" = "*Smith" } --- Someone with the last name
of Smith

This returns a 1 if true, 0 if false.  '*' is the multiple-character
wildcard, and '?' is the single-character wildcard.  The problem I'm having
is it doesn't seem to be able to handle 2 '*'s.  There is a chance that this
'Smith' could not be at the end and Name would look like "John Smith, Jr." or
"Jane Smith-Harris".

I've tried this:

{ COMPARE "{ MERGEFIELD Name }" = "*Smith*" }

but it always returns 0.

Is there some kind of workaround to this?

Any help is appreciated.

JASon
Peter Jamieson - 14 Oct 2004 10:37 GMT
I don't know of a way to fix this using fields, except by using a DATABASE
field to do the comparison, which can be complicated.

Other possible approaches are:
a. if your data source allows it, do the comparison using a query and
return an additional field that says whether the comparison succeeded or not
(or return an additional field containing the text you need, if that is
appropriate). This can be done in a number of ways depending on the data
source and your level of access to it. For example, in an Access query you
can use WHERE fieldname LIKE "*Smith*" (old syntax) WHERE fieldname LIKE
"%Smith%"(ANSI-92 syntax) to do this. If the data source can be accessed
using ODBC you will probably be able to use MS Query to set up something
similar, or you could use VBA to set up the query
b. if you are using Word 2002/2003, use VBA and the Word MailMerge events
to run VBA that does the comparison as each record is processed, and takes
appropriate action.

More info. available on these approaches depending on whether you think you
want to try any of them and which one seems likely to meet your needs.
Signature

Peter Jamieson

> I've figured out how to use the COMPARE functionality in a Word merge:
>
[quoted text clipped - 18 lines]
>
> JASon
 
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.