Problem
One of our Clients recently had a Word document within which they wanted some headings to be conditional based upon data from their Accounts/Contact Management Solution (CMS).
As an example these were the headings they wanted:
1. Red- Fixed Heading (Always 1)
2. Green – Conditional Heading
e.g. {IF { MERGE FIELD FROM CMS} = "1" "Green" "—No Heading--" \* MERGEFORMAT}
3. Black – Conditional Heading
e.g. {IF { MERGE FIELD FROM CMS } = "1" "Black" "—No Heading--" \* MERGEFORMAT}
4. Blue - Fixed Heading
If Items 2 and 3 aren’t in place Blue should be numbered 2.
Resolution
The first thing I tried was the SEQ field code, but what I found was the SEQ field behaved strangely within the IF Statement (Probably due to the timings of loading the data).
I did however find a solution using SET and REF:
At the beginning of the document I created a SET field
{SET numb 0} – To create a variable of 0
Within the document I then created the headings as follows:
{SET numb {=numb + 1}} {Ref numb}Red
{IF { MERGE FIELD FROM CMS} = "1" “{SET numb {=numb + 1}} {Ref numb} Green” “”}
{IF { MERGE FIELD FROM CMS} = "1" “{SET numb {=numb + 1}} {Ref numb} Black” “”}
{SET numb {=numb + 1}} {Ref numb}Blue
If you have any queries regarding SET, REF, SEQ, IF or any other field codes, ask us using the comments field below.
No comments:
Post a Comment