View Single Post
  #5  
Old March 25th, 2010, 05:16 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Date & Text format in Mail merge

{{IF "{MERGEFIELD Type}"="E" "email"} {IF "{MERGEFIELD Type}"="L"
"letter"}

This looks as if it is wrapped in an extra pair of field braces (i.e. it
is probably actually something more like

{{IF "{MERGEFIELD Type}"="E" "email"} {IF "{MERGEFIELD Type}"="L" "letter"}}

which will display nothing.

However, you had the right idea as

{IF "{MERGEFIELD Type}" = "E" "email"} {IF "{MERGEFIELD Type}" = "L"
"letter"}

should do it.

{IF "{MERGEFIELD Type}"="E" "email" "="L" "letter"}


The syntax is basically

{ IF operand1 operator operand2 true-result false-result }
or
{ IF operand1 operator operand2 true-result }

so the above would not work: you can nest, but typically you have to
spell things out, e.g.

{ IF "{ MERGEFIELD Type }" = "E" "email" "{ IF "{ MERGEFIELD Type }" =
"L" "letter" }" "something else" }

(It's advisable to put double-quotes around text operators but in many
situations they are not strictly essential)

See Graham Mayor's page at

http://www.gmayor.com/formatting_word_fields.htm

for other handy info. - I'd suggest you browse through

http://www.gmayor.com/Word_pages.htm




Peter Jamieson

http://tips.pjmsn.me.uk

On 25/03/2010 13:08, Andy Roberts wrote:
Peter

On a similar theme I presume I can use the IF command to check for different
values and replace accordingly. For exapmple one of my merge fields called
TYPE contains either E, L or F (email, letter, fax)

Thinking about it I presume I can insert the TYPE filed into a sentence
(e.g. "thank you for your "TYPE" ... but replace the relevant letter with a
piece of text (i.e. "thank you for your E" would become "thank you for your
email"...

The code im using is

{IF "{MERGEFIELD Type}"="E" "email" "="L" "letter"}

This only deals with the first replacement (i.e. the E)

I've also tried

{{IF "{MERGEFIELD Type}"="E" "email"} {IF "{MERGEFIELD Type}"="L" "letter"}

but I get nothing at all when I use this. I've learnt loads this morning
playing with this and I presume the problem is simply my syntax (and my lack
of knowledge!)