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 / March 2005

Tip: Looking for answers? Try searching our database.

How do I do a conditional mail merge into a table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tomtraff - 23 Mar 2005 13:59 GMT
I have a mail merge document with a table in which has a potential of 12 rows
of data depending on the results of the if statements.  Typically only one or
two of these rows get populated, so is there a way to remove or crunch down
the empty rows so that it looks like a one or two row table rather that a 12
row table with 2 rows populated
Cindy M  -WordMVP- - 24 Mar 2005 12:05 GMT
Hi =?Utf-8?B?dG9tdHJhZmY=?=,

> I have a mail merge document with a table in which has a potential of 12 rows
> of data depending on the results of the if statements.  Typically only one or
> two of these rows get populated, so is there a way to remove or crunch down
> the empty rows so that it looks like a one or two row table rather that a 12
> row table with 2 rows populated

In the mail merge FAQ on my website you'll find a discussion about complex
(one-to-many) merges. Two approaches are listed, with links to sample articles.
I suspect you could use the Database field one, although since you don't tell us
what the data source is, no guarantees.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Larry Cohen - 24 Mar 2005 22:57 GMT
I have a similar problem.  I cannot find a way to use a table without all
of the blank rows "showing"
I did find one way to do this, but only if only the same cell in each row
has the data that is tested and used by the if statement.
Like this:
Header row
Data1
Data2
Data3
Data4
Data5
Data6

If rows past any data level are blank, the blank rows colapse up.
If this is true, then I can give you a solution.

The other problem with this soluiton is that if the table splits accross a
page, you will not get another header row.

Larry
tomtraff - 29 Mar 2005 12:01 GMT
Larry,

I think you're solution could do the job, could you let me know how to do it

Thanks

Tom

> I have a similar problem.  I cannot find a way to use a table without all
> of the blank rows "showing"
[quoted text clipped - 16 lines]
>
> Larry
Larry Cohen - 29 Mar 2005 17:22 GMT
OK - let's say the data you are testing is called data_1, data_2, .... to
data_12.  You want to have the value for data_1 to print on one row,
followe by the value for data_2 on the next row, etc.   EXCEPT if and
data_# is blank, you want that row to collapse.

So the first step is to construct the table.  Use the "Insert table" icon
to build the table with the number of columns desired, BUT with only 2 rows.

In the first row, type in the headers you want visible - that is fixed text
describing the column headings.  

Next go to the first position on the next row (the only other row) that
will have the data_# value.  This is where we are going to insert the first
IF....THEN....ELSE statement.  I do this differently than most of the
commenters - I use the "Insert Word Field" button.  (If this is not on your
mail merge toolbar ... use the drop-down arrow at the end of the toolbar,
add/or remove button .... click on mail merge, and click on the Insert Word
Field.

Back to that first position - click on the Insert Word Field and select
IF...THEN....ELSE.  This opens a dialog box.  In the Field name drop-down,
select the first keyword (Data_1).  In the Comparison drop-down box, select
"is not blank."  You do not need to fill in anything else; press ok.  Now
hold down the ALT key and press/release F9 key.  This will show you the
actual mail merge code. In the table cell you will now see:
{IF MERGEFIELD DATA_1 } <> "" "" "" }
That means, if the data_1 value is not null (first ""), then do what is
inside the second "", or if it is blank, do what is inside the third "".

Now place your cursor inside the second set of ""( where I show the plus
sign below).  
{IF MERGEFIELD DATA_1 } <> "" "+" "" }
Then click on Insert Merge Field and select DATA_1. See below:
{IF MERGEFIELD DATA_1 } <> "" "{ MERGEFIELD "DATA_1" }" "" }

So this will print the value of Data_1 if it is not blank.  Now this is an
IMPORTANT step.  Move your cursor to the point just after the last curly
brace. See the plus below:
{IF MERGEFIELD DATA_1 } <> "" "{ MERGEFIELD "DATA_1" }" "" }+

At this point add the next IF...THEN...ELSE   see below:
{IF MERGEFIELD DATA_1 } <> "" "{ MERGEFIELD "DATA_1" }" "" }{IF MERGEFIELD
DATA_2 } <> "" "" "" }

The above may display on this site split into two lines.
OK, now the next IMPORTANT step.  Go to the point in the second If
statement - the second set of "" where we will insert the "insert merge
field"  but do not do that yet.

See the plus sign below:
{IF MERGEFIELD DATA_1 } <> "" "{ MERGEFIELD "DATA_1" }" "" }{IF MERGEFIELD
DATA_2 } <> "" "+" "" }

Put your cursor there between the second set of "" and key in 2 returns,
and then insert merge field (data_2).  It should look like below:

{IF MERGEFIELD DATA_1 } <> "" "{ MERGEFIELD "DATA_1" }" "" }{IF MERGEFIELD
DATA_2 } <> "" "

"{ MERGEFIELD "DATA_2" }" "" }Next If statement here.

You will keep doing the above until you have your 12 mergefiedl
IF..THEN..ELSE statements.
What we have done is use one cell to hold all of the "rows" separating each
active row with a blank line.  So you might see

Label row
---------------------
Data_1

Data_3

or

Label row
---------------
Data_5

Data_7

Data_8

Data_10

Hope this helps.
I actually found a way, in my application which required over 100 rows, to
copy the label row to each page.  That's for another time.
Larry Cohen - 29 Mar 2005 17:29 GMT
I forgot to mention, that after you finish - use the ALT+F9 to toggle off
the reveal codes.  That lets you see your results as you move through your
list using the > and < keys on the mail merge toolbar.  You will see the
results of the If..then...else even if the "ABC" is not depressed - because
the if...then..else are live functions.  If you want to see your other
inserts in the merge, press the "ABC" button on the mail merge toolbar.
 
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.