Home |
Search |
Today's Posts |
#1
|
|||
|
|||
How do I do a conditional mail merge into a table
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 |
#2
|
|||
|
|||
Hi ?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 :-) |
#3
|
|||
|
|||
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 -- Message posted via http://www.officekb.com |
#4
|
|||
|
|||
Larry,
I think you're solution could do the job, could you let me know how to do it Thanks Tom "Larry Cohen via OfficeKB.com" wrote: 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 -- Message posted via http://www.officekb.com |
#5
|
|||
|
|||
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. -- Message posted via http://www.officekb.com |
#6
|
|||
|
|||
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. -- Message posted via http://www.officekb.com |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
mail merge with attachments | Mailmerge | |||
How do I use a table of contents in a mail merge | Mailmerge | |||
Specific Email Merge w/ Specific Attachements | Mailmerge | |||
Convert Table Labels to do Mail Merge? | Mailmerge | |||
Conditional mail merge | Mailmerge |