One of six styles in the heading - Word 2003/2007/2010

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

One of six styles in the heading - Word 2003/2007/2010

Post by Robie »

I have six different styles defined - essentially they are same except for the bullet (picture) is different for each. All other parameters are same.

EDIT: The user can only have one of these styled paragraph defined in the document, i.e. they are mutually exclusive.

Now, within the document the user may use one of these styles. Also, the used style content is also used as part of the header for the document. How, can I set up the header so that only the style used in the document is reflected and other styles *do not* show the error, i.e. if the document is defined with styleblue then all others return an error. My header is defined with styleref for all six different styles as follows:
03.png
Thanks.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78492
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: One of six styles in the heading - Word 2003/2007/2010

Post by HansV »

If the user can use only one of these styles, I'd use a single style PSH, refer to that in a single STYLEREF field, and change the bullet colour as needed.
Best wishes,
Hans

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: One of six styles in the heading - Word 2003/2007/2010

Post by Robie »

HansV wrote:If the user can use only one of these styles, I'd use a single style PSH, refer to that in a single STYLEREF field, and change the bullet colour as needed.
Interesting.

Remember the bullets are actually *images* not just differently coloured bullets. Is it actually viable to change the bullet image ' on the go sort of speak'?

User avatar
StuartR
Administrator
Posts: 12608
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: One of six styles in the heading - Word 2003/2007/2010

Post by StuartR »

For each of the styles that you may have in the document you could include

{ IF { STYLEREF "Style name here" } = "Error! No text of specified style in document" "" "{ STYLEREF "Style name here }"

Here is an example from a document of mine that may have a Heading 1 style or may have an Appendix 1 style, and I want this to be include in the header.
You do not have the required permissions to view the files attached to this post.
StuartR


User avatar
HansV
Administrator
Posts: 78492
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: One of six styles in the heading - Word 2003/2007/2010

Post by HansV »

Robie wrote:
HansV wrote:Is it actually viable to change the bullet image ' on the go sort of speak'?
As far as I can tell, you cannot set the bullet image from an AutoText entry (or Building Block), it has to be from an external file, so that would not be practical.
Best wishes,
Hans

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: One of six styles in the heading - Word 2003/2007/2010

Post by Robie »

StuartR wrote:For each of the styles that you may have in the document you could include

{ IF { STYLEREF "Style name here" } = "Error! No text of specified style in document" "" "{ STYLEREF "Style name here }"

Here is an example from a document of mine that may have a Heading 1 style or may have an Appendix 1 style, and I want this to be include in the header.
Thanks Stuart.

I think that works works for me. Let me try it out.

CHEERS.

User avatar
HansV
Administrator
Posts: 78492
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: One of six styles in the heading - Word 2003/2007/2010

Post by HansV »

One thing to keep in mind: if your document will be viewed by users with a non-English version of Word, Stuart's solution won't work. The error messages are language-dependent - if you open the document in the French version of Word, the error message would be "Erreur! Il n'y a pas de texte répondant à ce style dans ce document", so

{ STYLEREF "Style name here" } = "Error! No text of specified style in document"

would not be true.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12608
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: One of six styles in the heading - Word 2003/2007/2010

Post by StuartR »

I tried replacing the literal text "Error! No text of specified style in document" with a Styleref for a non-existent style, but it generated the error message "Error! Use the Home tab to apply No such style to the text that you want to appear here."

I then tried replacing it with a Styleref that referred to "Heading 9" style, which I have not used anywhere in the document, but this generated the same unhelpful text. It appears that you only get the text "Error! No text of specified style in document" for a style that has been used in the document at some time, or a style that is in the "recommended" list in the style gallery.

Another good idea bites the dust.
StuartR


User avatar
HansV
Administrator
Posts: 78492
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: One of six styles in the heading - Word 2003/2007/2010

Post by HansV »

Stuart,

As long as the document will only be viewed in the English version of Word, your suggestion will work fine!
Best wishes,
Hans

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: One of six styles in the heading - Word 2003/2007/2010

Post by Robie »

HansV wrote:Stuart,

As long as the document will only be viewed in the English version of Word, your suggestion will work fine!
Thanks Stuart and Hans.

In my case it is ENGLISH language only so Stuart your code will work fine. Woohoo. :clapping:

User avatar
StuartR
Administrator
Posts: 12608
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: One of six styles in the heading - Word 2003/2007/2010

Post by StuartR »

HansV wrote:...As long as the document will only be viewed in the English version of Word, your suggestion will work fine!
But it should be possible to find another way to create this same error message for use in the { IF } field.
StuartR