Mail Merge and Tables

D

Daryl

I have information in a spreadsheet that is a being merged
into Word table. The problem I have is that some rows,
when merged, will be blank. Is there a way to
automatically not to have blank rows. I know that this
can be done in a paragraph without a problem, but I can't
seem to do it in a table. (Also, I am using a
if...then...else to not display values with 0).


Example (Word table, without if/then/else applied)

Apples 1
Bananas 2
Pears 0
Plums 3


Example (Word table, with if/then/else applied)

Apples 1
Bananas 2

Plums 3


Desired Output in Word table

Apples 1
Bananas 2
Plums 3
 
P

Peter Jamieson

There isn't really a way you can do this using fields alone in Word. The
closest you can get is probably to put the entire table row inside the
result text of an IF field, but as you have discovered that leaves gaps in
your output. To close them up, you would probably have to merge to an output
document and write VBA to remove them.

The way Word "expects" you to do this is to define query options or select
records in the data source before merging. Then Word only "sees" the records
you want and ignores the rest altogether. In Word 2002 and later you can use
Select Recipients for that, but itisn't obvious how to define "where value
<> 0" - click the label of the "value" column and seect the Advanced...
option, then you should see a query options dialog that will allow you to
specify a small number of filters. In Word 2000 or earlier, the Query
options button may take you to the same dialog. There are other
possibilitites but that is probably the one you should try first.
 
M

macropod

Hi Daryl,

You could do this with fields, if you really wanted to,
but it would mean either -
(a) having a separate table for each row, since Word can't
output a table without a preceding para mark in a field; or
(b) using 2^n nested IF statements and tables to output
the results, where n is the number of rows in the table.
Thus, for just 3 conditions, you would have 8 possible
table outputs, ie:
{QUOTE
{MERGEFIELD BkMrk1}{MERGEFIELD BkMrk2}{MERGEFIELD BkMrk3}
{IF{=AND({=AND(({Bkmrk1}=0),({Bkmrk2}=0))},({Bkmrk3}=0))}=
1 "
Table1 goes here
" {IF{=AND({=AND(({Bkmrk1}=0),({Bkmrk2}=0))},({Bkmrk3}=1))}
= 1 "
Table2 goes here
" {IF{=AND({=AND(({Bkmrk1}=0),({Bkmrk2}=1))},({Bkmrk3}=0))}
= 1 "
Table3 goes here
" {IF{=AND({=AND(({Bkmrk1}=0),({Bkmrk2}=1))},({Bkmrk3}=1))}
= 1 "
Table4 goes here
" {IF{=AND({=AND(({Bkmrk1}=1),({Bkmrk2}=0))},({Bkmrk3}=0))}
= 1 "
Table5 goes here
" {IF{=AND({=AND(({Bkmrk1}=1),({Bkmrk2}=0))},({Bkmrk3}=1))}
= 1 "
Table6 goes here
" {IF{=AND({=AND(({Bkmrk1}=1),({Bkmrk2}=1))},({Bkmrk3}=0))}
= 1 "
Table7 goes here
" {IF{=AND({=AND(({Bkmrk1}=1),({Bkmrk2}=1))},({Bkmrk3}=1))}
= 1 "
Table8 goes here
}}}}}}}}}

Solution (a) might be OK if you format the font for the
para marks within the field to 1pt and no leading space.
If you needed to do math on the displayed results, you'd
need to bookmark each table and use inter-table
referencing (see Word's help file).

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top