PDA

View Full Version : [SOLVED:] Word Field code IF - Else backspace?



KilpAr
08-30-2017, 09:07 AM
Hi,

I have a docx-document that has fields like this

Listed here are our customers
Customer1
Customer2
Customer3
Customer4
Customer5
And that's the customers we have

The field formula is (on pseudolevel): IF { {DOCPROPERTY "Customer1"} <> "Error! Unknown document property name." {DOCPROPERTY "Customer1"} " ""}
which basically works, but I don't like the idea that with one customer it looks like this:

Listed here are our customers
Customer1




And that's the customers we have

because it has disturbing empty lines, and it should instead look like:


Listed here are our customers
Customer1
And that's the customers we have


So is there a way to give on that else-branch a command of backspace i.e. delete the entire line if no value exists?

macropod
08-30-2017, 03:13 PM
The solution is as simple as putting the paragraph break into the IF test:
{IF{DOCPROPERTY "Customer1"} <> "Error!*" "{DOCPROPERTY "Customer1"}¶
"}{IF{DOCPROPERTY "Customer2"} <> "Error!*" "{DOCPROPERTY "Customer2"}¶
"}{IF{DOCPROPERTY "Customer3"} <> "Error!*" "{DOCPROPERTY "Customer3"}¶
"}
etc.

KilpAr
08-30-2017, 05:46 PM
The solution is as simple as putting the paragraph break into the IF test:
{IF{DOCPROPERTY "Customer1"} <> "Error!*" "{DOCPROPERTY "Customer1"}¶
"}{IF{DOCPROPERTY "Customer2"} <> "Error!*" "{DOCPROPERTY "Customer2"}¶
"}{IF{DOCPROPERTY "Customer3"} <> "Error!*" "{DOCPROPERTY "Customer3"}¶
"}
etc.

Oh nice! I haven't tested this yet, but sounds logical.

Thanks!