Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Conditional create table
Hi All
I'm a complete beginnier at mail merges so please be gentle. I've inherited a mail merge were we want to have a formatted table only if there is data present. The number of rows in the table (excluding header) can be between 0 and 3, if its 0 then dont show the table, otherwise only the rows with data. Any help or pointers would be very much appreciated. cheers Keith |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Conditional create table
This sounds like a list sorted by category -
http://support.microsoft.com/?kbid=294686 Fellow MVP 'macropod' has posted a tutorial on this, with working field codes and a sample Excel data source which you can download from my website http://www.gmayor.com/Zips/Catalogue%20Mailmerge.zip Do read the instructions BEFORE jumping in. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org wrote: Hi All I'm a complete beginnier at mail merges so please be gentle. I've inherited a mail merge were we want to have a formatted table only if there is data present. The number of rows in the table (excluding header) can be between 0 and 3, if its 0 then dont show the table, otherwise only the rows with data. Any help or pointers would be very much appreciated. cheers Keith |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Conditional create table
How to do this depends on precisely how you determine how many rows you
need and what should be in them. If te table only relates ot a single data source, then it would typically be something like a. If fielda is non-blank, insert a row containing fielda b. if fieldb is non-blank, insert a row containing fieldb c. if fieldc is non-blank, insert a row containing fieldc In that scenario, there are 7 possible tables that actually contain anything and you could a. insert a nested IF field that contains each of the 7 tables, e.g. { IF "{ MERGEFIELD fielda }" = "" "{ IF "{ MERGEFIELD fieldb }" = "" "{ IF "{ MERGEFIELD fieldc }" = "" "" "put the table and fields for a table with a fieldc row only here" }" "{ IF "{ MERGEFIELD fieldc }" = "" "put the table and fields for a table with a fieldb row only here" "put the table and fields for a table with fieldb and fieldc here" }" "similar stuff for the case where fielda is non-blank" } All the {} have to be the special field code braces that you can insert using ctrl-F9. You can toggle bewteen field codes and results using alt-F9. You can put text, complete tables, and field codes inside the IF "results" as I have indicated. Probably slightly simpler in some respects would be to calculate a "table number", e.g. where fielda "" counts 4, fieldb blank counts 2 and fieldc "" counts 1. Then table 6 would be the table with non-blank fielda and fieldb, but blank fieldc. You could do that as follows: { SET tablenumber { =4*{ COMPARE "{ MERGEFIELD fielda }" "" } + 2*{ COMPARE "{ MERGEFIELD fieldb }" "" } + { COMPARE "{ MERGEFIELD fieldc }" "" } } Then you can have a separate IF for each table and avoid nesting, e.g. { IF { REF tablenumber } = 1 "table and fields for fieldc only" "" }{ IF { REF tablenumber } = 2 "table and fields for fieldb only" "" }{ IF { REF tablenumber } = 3 "table and fields for fieldb and fieldc only" "" } etc. Of course /your/ conditions could be more complex (IMO separating a calculation based on the conditions from the actual business of the layout is probably even more useful in that case) or you may be getting data from multiple records, in which yu would need a rather different approach. Peter Jamieson http://tips.pjmsn.me.uk wrote: Hi All I'm a complete beginnier at mail merges so please be gentle. I've inherited a mail merge were we want to have a formatted table only if there is data present. The number of rows in the table (excluding header) can be between 0 and 3, if its 0 then dont show the table, otherwise only the rows with data. Any help or pointers would be very much appreciated. cheers Keith |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Conditional create table
Hi Guys
Thanks for the posts. It was a little more complicated, the data came from a excel spreadsheet and was split horizontally rather than vertically. In the end i went with using VBA to query the mergefields to see if they contained a value, used that to work out the number of rows needed, and then build the table programmatically. Theres probably a better way, but that took less time to learn. Ah, the whooshing sound of deadlines. cheers keith |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to conditional format in a Word table | Tables | |||
Conditional checkboxes within a table | Tables | |||
create conditional data in label mail merge | Mailmerge | |||
how do i create conditional text in Word docs | Microsoft Word Help | |||
Possible to create conditional checkboxes in Word? | Microsoft Word Help |