STYLEREF field updates only sometimes

Hi everyone,

 

I'm using the Dutch version of Word 2013.

 

In a template for reports I have created for one of my clients, the header should display:

- text in the style “Bijlage” whenever the report has an enclosure;

- the text “Colofon” at the colophon at the beginning of the report;

- the text “Inhoudsopgave” at the table of contents at the beginning of the report, directly after the colophon;

- text in the style “Kop 1” (Heading 1) elsewhere.

 

In order to achieve this behavior I have included this field in the header:

 

{ IF { BijlageTitelCompleet01 } = “Fout! Bladwijzer niet gedefineerd.” { IF { PAGE } <= { PAGEREF Inhoudsopgave } { STYLEREF “ColofonInhoud” } { STYLEREF “Kop 1” } } { IF { PAGE } >= { PAGEREF BijlageTitelCompleet01 } { STYLEREF Bijlage} { IF { PAGE } <= { PAGEREF Inhoudsopgave } { STYLEREF “ColofonInhoud” } { STYLEREF “Kop 1” } } } }

 

"Fout! Bladwijzer niet gedefinieerd." translates to "Error! Bookmark not defined." in English Word versions.

If a report has one or more enclosures, the bookmark BijlageTitelCompleet01 encapsulates the title of the first enclosure.

The bookmark Inhoudsopgave resides on the page with the table of contents.

Both the colophon and the table of contents contain the right tekst (“Colofon” resp. “Inhoudsopgave”) in the style “ColofonInhoud”.

 

The field displays text as intended; the trouble is that it only does so every now and then. Or better: "Colofon" and "Inhoudsopgave" show up all the time at the right locations so that's fine - but any texts in "Kop 1" style or "Bijlage" style remain invisible. F9 does not work. Sometimes however - hey presto! -  all of a sudden the field does display text in those styles, and this seems to happen when I copy individual parts of the large field elsewhere in the header in order to check their results. I cannot lay my finger on when exactly the field starts behaving like it should. This is highly frustrating - especially because I cannot think of an alternative approach to achieve the desired results.

 

What is happening here, and how can I get the field to behave correctly?

 

Thank you,

Cooz

Answer
Answer

I don't know if Suzanne's suggestion has worked for you - if so, you can ignore this suggestion.

I have also found that execution of IF fields in headers and footers can sometimes not work as expected, and that things work correctly outside the IF but not inside. But I do not know the cause either. It is true that Word updates header/footer fields quite frequently when you move around the document, and may struggle in the case of complex fields, but I do not think that is the cause here (Actually, right now I cannot replicate, but document size may be a factor).

However, another way that you may be able to achieve this without even having an IF field is to use the following nested field code instead:

{ STYLEREF "{ REF "Part{ SEQ Part \c }" }" }

To make that work, you also need to do the following.I only give an outline for the moment because (a) it is not worth doing unless tests suggest that it functions correctly with your document, and (b) the details depend on precisely how you need to do things.

1. put the following fields at the beginning of your document

{ SEQ Part \r0 \h }{ SET Part0 "ColofonInhoud" }{ SET Part1 "Kop 1" }{ SET Part2 "Bijlage" }

2. Put the following code on the page after your Table of Contents (ToC):

{ SEQ Part \r1 \h }

3. Put the following field code in any inclusion (or arrange for the field code to be there if there are any inclusions):

{ SEQ Part \r2 \h }

In a header, Word will pick up the value that the SEQ field has at the bottom of the page, so you need to ensure that if your inclusion is the first thing after your ToC, the { SEQ Part \r2 \h } is on the same page, lower than the { SEQ Part \r1 \h }

 A few notes:

You can probably put the SET fields in the header.

SInce Word quietly initialises a SEQ sequence to 0 at the beginning of the document, the first { SEQ } could be omitted altogether.

AFAICS using { SET Part1 1 } works OK and avoids the Heading 1/Kop 1 localisation probem. { STYLEREF 1 }/{ STYLEREF "1" } are AFAIK not properly documented but Word uses that abbreviation itself. Further, if you actually create a style called "1", { STYLEREF 1 } still seems to pick up Heading 1/Kop 1.


Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 614 Applies to: