Share via

StyleRef field plus some text

Anonymous
2016-09-01T08:55:01+00:00

Hi all

This should be an easy one :)

I have a StyleRef field (and thanks to macropod, et al) only displays when the style in question is used in the file.

What I would like to do is add some text to the StyleRef field, so when the field displays it shows the StyleRef-text and the plain text as well.

{STYLEREF  "StyleName" "text"}

but I don't know the switches/syntax for this to work

cheers :)

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

8 answers

Sort by: Most helpful
  1. Suzanne S Barnhill 278.1K Reputation points MVP Volunteer Moderator
    2016-09-02T13:34:36+00:00

    All I can say is that it works as expected for me (I used Heading 1 as the referenced style). The position of the quotes is crucial. You must have quotes around the entire TrueText and around the stylename if it is more than one word but not anywhere else, lest Word interpret it as FalseText.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-09-02T06:03:18+00:00

    Thanks Suzanne for the reply

    sorry but this does not work for me, the "text" appears regardless of the style use.

    If there is no text with the Style that the StyleRef is looking for, there is nothing displayed.

    If the style is used, the text with the style AND the "text" to appear.

    Say Jabberwocky is the text with the style applied, then the StyleRef field should display "Jabberwocky text".

    If style not used, nothing displayed.

    Many thanks :)

    Was this answer helpful?

    0 comments No comments
  3. Suzanne S Barnhill 278.1K Reputation points MVP Volunteer Moderator
    2016-09-01T16:11:57+00:00

    You can use a field as TrueText without quotes, but once you add anything to it, you need the quotes, so what you need here is (you can omit the FalseText since it's blank):

    { IF { STYLEREF "stylename" } <> "Error!*" "{ STYLEREF "stylename" } text" }

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2016-09-01T09:46:01+00:00

    here is what I have (from macropod)

    { IF{STYLEREF "stylename"}<> "Error!*" {STYLEREF "stylename" } }

    this works fine, displaying and not displaying the styleref text as required

    but if I add (like you say - if I got it right)

    { IF{STYLEREF "stylename"}<> "Error!*" {STYLEREF "stylename" } text" " " }

    the styleref is displayed but not the extra text

    I tried your code, the standard error is displayed if the style not used, and the Text is displayed regardless; I am after the text not to displayed when style not used and no error shown; and the text to display along with the StyleRef-text.

    Was this answer helpful?

    0 comments No comments
  5. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2016-09-01T09:23:35+00:00

    I am not sure what the StyleRef field construction that you are using returns if the style is NOT used in the file, but assuming that it is a space, you could use a construction such as

    { IF { STYLEREF "StyleName" } <> " " "{ STYLEREF "StyleName" } text" " " }

    Was this answer helpful?

    0 comments No comments