Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Suppress printing of a MAILMERGE field if it's blank

4,414 views
Skip to first unread message

Henry

unread,
Nov 3, 2010, 7:44:39 PM11/3/10
to
I'm sure this has been asked and answered many times, but I need to ask
again, in any case.

I've been thrown into a major project involving Word 2003 mailmerge
documents. A big problem is that there is not yet - or, maybe, never
will be, for certain fields - proper data.

In particular, the name prefix - such as "Mr." or "Miss" - is supposed
to be populated in the database but is essentially nonexistent. When a
document prints, and such a field has no data, it prints <None> This is
not acceptable and it certainly doesn't look very good. I've been
looking at lots of Google-searched solutions involving field
placeholders {} but it seems that the series of steps to create a merge
field with an IF statement is very particular. In addition, if it's
blank, it shouldn't take up a space. In other words, if I have
something like:

<<client_Prefix>> <<client_firstname>> and the prefix is blank,
<<client_firstname>> shouldn't appear offset by two spaces from the left.

When I <Insert><Field><Merge field> and type in a name, the field is
formatted with chevrons << >> properly. However, if I try to ad, or
change to, an IF field, all that gets printed is MERGEFIELD or the name
of the merge field, such as "client_prefix"

I'd be grateful if somebody could point me in the right direction. I've
played with first clicking CTRL_F9 to add {} to the document and then
directly adding the IF expression but this hasn't worked, either.
Thanks in advance for any assistance.

Lisa Wilke-Thissen

unread,
Nov 4, 2010, 12:01:19 PM11/4/10
to
Hello Henry,

"Henry" wrote

[Word 2003]


> I've been looking at lots of Google-searched solutions involving
> field placeholders {} but it seems that the series of steps to create
> a merge field with an
> IF statement is very particular.

choose "View | Toolbars | Mail Merge". In the toolbar you will find a
command "Insert Word Field | If.. then ... else". Now you can "build"
your If-statement.

> In addition, if it's blank, it shouldn't take up a space. In other
> words, if I have something like:
> <<client_Prefix>> <<client_firstname>> and the prefix is blank,
> <<client_firstname>> shouldn't appear offset by two spaces from the
> left.

Don't add a space between the Mergefields. Instead, right click on the
field "client_Prefix", choose "edit field" and enable "space after"
inserting a space.
Now a switch (\f) and a space between quotes has been added to the
field: { MERGEFIELD client_Prefix \ f " "}
To toggle between field codes and results use ALT + F9.

> the field is formatted with chevrons << >> properly.

Maybe properly ... but you will not see the field code behind. Use
Alt+F9 to show the field code.

--
Cheers
Lisa [MS MVP Word]

Henry

unread,
Nov 5, 2010, 10:28:40 PM11/5/10
to
Thanks very much for the reply, Lisa.

The If...Then...Else builder definitely adds some capabilities I could
use - and didn't know about. There's one problem, though - the "Insert
Word Field" menu option is only available if the document has been set
up as a Letter. All of the documents I'm working with have been set up
as normal Word documents. If I then click the "Merge document setup"
icon and change the document to "Letter" I can, indeed, insert an
"If...Then...Else..." field, but the first item to be selected is "Field
name" - but no field names are listed, and you cannot simply type in a
name. As a result, I'm unable to utilize this utility. Am I still
missing something?

I checked this on my laptop - using Word 2002, and I remotely logged on
to my computer at work which uses Word 2003, with the same results. Is
there a way around this, or do I have any ether options?

Of course, now I have to read about the other types of fields available
via the "Insert Word field" utility... it never ends... aaarrggghh...

Graham Mayor

unread,
Nov 6, 2010, 3:30:35 AM11/6/10
to
You can manually enter any field, including merge fields, from the keyboard
using CTRL+F9 for the field boundaries, and that is the easiest way to do it
once familiar with the syntax e.g.

{IF{ Mergefield Fieldname } <> "" "{Mergefield Fieldname}"}

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

"Henry" <gree...@optonline.net> wrote in message
news:4cd4bd3b$0$31276$607e...@cv.net...

Henry

unread,
Nov 6, 2010, 10:21:53 AM11/6/10
to
This includes the Else as well, yes?

So the format would be:

{ If { MERGEFIELD client_prefix } = "" "{ MERGEFIELD client_lastname }"
ELSE "{ MERGEFIELD client_prefix }" " " "{client_last_name }" }

Would that be about right? If the prefix is blank, just print the last
name, otherwise print the prefix and a space and the last name.

Thanks again for your help.

Graham Mayor

unread,
Nov 6, 2010, 11:08:51 AM11/6/10
to
Not quite. It should be

{IF TEST = CONDITION "DO THIS" "ELSE DO THIS" } thus

{ IF { Mergefield client_prefix } = "" "{ Mergefield client_lastname }" "{
Mergefield client_prefix } { Mergefield client_lastname }" }

Or even simpler

{ IF { Mergefield client_prefix } <> "" "{ Mergefield client_prefix } " }{
Mergefield client_lastname }

Note the space between the field and the quote in the second version. There
is no space between the fields.

Note also that you had two different spellings for the last name field name?
I have shown one of them ;)

You may find http://www.gmayor.com/formatting_word_fields.htm useful.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

"Henry" <gree...@optonline.net> wrote in message

news:4cd56482$0$7147$607e...@cv.net...

Henry

unread,
Nov 6, 2010, 12:04:39 PM11/6/10
to
That's excellent! Thanks! I will have to give that a try. As far as
the two different spellings goes - well, my fingers ran away from my brain.
It happens.

Graham Mayor

unread,
Nov 7, 2010, 7:42:54 AM11/7/10
to
You are welcome. :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

"Henry" <gree...@optonline.net> wrote in message

news:4cd57c98$0$7113$607e...@cv.net...

Henry

unread,
Nov 13, 2010, 4:20:40 PM11/13/10
to
A small side note:

I found that I had to test for the string "<None>" and not "" to
actually handle a blank merge value. I believe that <None> is how the
system was handling a NULL database value.
Now I put that in my toolbox for the future - one more wheel I don't
have to reinvent.

Graham Mayor wrote:
> You are welcome. :)
>
>

0 new messages