View Single Post
  #4  
Old March 25th, 2010, 01:08 PM posted to microsoft.public.word.mailmerge.fields
Andy Roberts
external usenet poster
 
Posts: 183
Default Date & Text format in Mail merge

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!)


--
Regards

Andy

Andy Roberts
Win XP, Office 2007
"Peter Jamieson" wrote in message
...
What do you see when the value is ASAP and you use the mergefield with no
format definition, i.e.

{ MERGEFIELD "Date Required" }

?

If you are using Word 2002 or later and you used the default connection
method (OLE DB - if you don't know what connection method you used then
it's almost certainly OLE DB) then you will probably see a time such as

"12:00:00 AM"

In that case you can try

{ IF "{ MERGEFIELD "Date Required" }" = "12:00:00 AM" "ASAP" "{ MERGEFIELD
"Date Required" \@"DD/MM/YY" }" }

Each pair of {} needs to be the "special field braces" that you can insert
using ctrl-F9.

If you happen to have connected using ODBC (unlikely these days) then you
will probably see a blank result, and as long as you do not need to
distinguish between ASAP and a blank cell, you can use

{ IF "{ MERGEFIELD "Date Required" }" = "" "ASAP" "{ MERGEFIELD "Date
Required" \@"DD/MM/YY" }" }

If you happen to have connected using DDE (the default in Word 2000 and
earlier), then you should see "ASAP". In that case,

{ MERGEFIELD "Date Required" \@"DD/MM/YY" }

should display the correct result, but if not, you can try

{ IF "{ MERGEFIELD "Date Required" }" = "ASAP" "ASAP" "{ MERGEFIELD "Date
Required" \@"DD/MM/YY" }" }

Although you may be able to fix this by changing your connection method to
DDE, I find it difficult to recommend that these days.

See http://tips.pjmsn.meuk/t0003.htm for further info.

Peter Jamieson

http://tips.pjmsn.me.uk

On 25/03/2010 07:53, Andy Roberts wrote:
I have a spreadsheet which lists jobs and one of the columns is a
"required
date" value which sometimes is unknown so instead of a date we input
"ASAP" - this works fine in the spreadsheet.

I then have a mail merge document which brings in the "required date"
field
and is formatted as follow:-
{MERGEFIELD Date Required\@"DD/MM/YY"}

This works ok when it is merging a date but doesn't work when it finds
"ASAP" instead of a date. I understand that it is formatted to a date
format which is the problem but if I remove this formatting I get a US
date
format. I dont want to leave the excel cell blank as this looks as though
the inputter has missed something.

Is there anyway around this?