Mail-Merge 2010 using "LIKE"

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Mail-Merge 2010 using "LIKE"

Post by PaulW »

In Access queries I use [Like ("*@*.*")] to determine if the field is an email address. I have an Excel worksheet and wish to determine if a field in that worksheet contains an email address from within a mail-merge document. This is something like an if/else, but I can't find the proper syntax (if there is one).

TIA
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Mail-Merge 2010 using "LIKE"

Post by macropod »

Word fields don't provide much support for wildcard comparisons. Sure, you can use * (for a variable-length string) and ? (for a single character) in comparisons like ???@* (to find three characters followed by an @ then any number of characters after that), but you can't use *@*. Effectively, that means you'd need to test every position the @ might occur in, via a series of comparisons like ???@*, ????@*, ????@* and so on to find whether you might be dealing with an email address.
Paul Edstein
[Fmr MS MVP - Word]

User avatar
HansV
Administrator
Posts: 78381
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Mail-Merge 2010 using "LIKE"

Post by HansV »

Perhaps it'd be easier to filter the data in Excel?
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Mail-Merge 2010 using "LIKE"

Post by PaulW »

Thanks to all who replied. :clapping:

I found the following:

Code: Select all

=ISERROR(SEARCH("*@*.*",A1))
AT (@)

http://www.pcreview.co.uk/forums/scanni ... 98419.html

This code reacts the same way that the Like ("*@*.*") responds in Access.

I am not sure that the mail-merge will accept TRUE and FALSE, so I changed it to return a "Y" or an "N".
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78381
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Mail-Merge 2010 using "LIKE"

Post by HansV »

Good to hear that you found a solution. Thanks for the feedback.
Best wishes,
Hans