Categories > OpenTBS with DOCX >

Help for hiding conditional text in MS Word document

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Jules Mimeault
Date: 2015-12-21
Time: 16:23

Help for hiding conditional text in MS Word document

Hello,

After having consulted many posts here, I haven't found how to hide some literal text that should be displayed preceding the second of 2 fields only when the content of the second field is not empty.

On each line I have a title followed by the author (or 2 authors if there are 2). I would like to put " / " between the 2 authors'names only when there is a second author.
N.B. Every author's name is made of 2 fields: initial and surname.

Here is my code in the template:

[a.title;block=w:p] ([a.initial1] [a.surname1] / [a.initial2] [a.surname2])

Obviously I would like also to eliminate the space between initial2 and surname2 if there is no second author.

Thanks for your help


By: Skrol29
Date: 2015-12-22
Time: 00:51

Re: Help for hiding conditional text in MS Word document

This should work:

The part of the text "/ [a.initial2;magnet=w:t] [a.surname2]" must have a different style, like having a font color with a different black.
The use parameter "magnet" :
[a.title;block=tbs:p] ([a.initial1] [a.surname1] / [a.initial2;magnet=w:t] [a.surname2])
By: Jules Mimeault
Date: 2015-12-22
Time: 03:57

Re: Help for hiding conditional text in MS Word document

Hello,

Thanks for your answer. I tried it but the result is not satisfying.
The fact that the text "/ [a.initial2;magnet=w:t] [a.surname2]" must have a different style for the magnet to be working is a problem.
And then the final closing parenthesis that should stay there is also deleted.
What I desire as a result is: Title in normal style; Opening parentheses in normal style; initial and name of the first author in italic; " / " in normal style; initial and name of the second author in italic; closing parenthese in normal style.

I wonder if a solution would be possible using absolute explicit syntax to define blocks for the different parts of this line of text.
Or maybe it would be easier to find a solution using OpenOffice?
And I think it could be useful also for other people. In fact is just an example of punctuation between 2 fields that should show or hide according to the presence or not of both fields. There could be many applications to this.
Thanks in advance for your help and your patience.
God bless.