The problem is that the Styleref field searches for the first occurence
of a style (eg, Heading) up or down in the entire document, not just
the current page. So if you are on a page that only goes up to H3, it
would include the H4 from several pages hence in the document. There's
no way to use the PageRef or other fields to pick up the page number of
the StyleRef that it finds... but here's how I solved it:
Creating a character style that has no attributes, HeadChar, and
applying it with global search-replace to all headings. Then searching
for the first 'HeadChar' from the bottom up (\l), and if it matches a
style level, insert that style with all the previous levels. So, for
example, for level 3: {IF {STYLEREF "Heading 3" \n \l} = {STYLEREF
"HeadChar" \n \l} "{STYLEREF "Heading 1" \n \l} {STYLEREF "Heading 1"
\p \l} > {STYLEREF "Heading 2" \n \l} {STYLEREF "Heading 2" \p \l} >
{STYLEREF "Heading 1" \n \l} {STYLEREF "Heading 1" \p \l}" }
It works!
--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
<jon.h...@gmail.com> wrote in message
news:1158898504....@m73g2000cwd.googlegroups.com...
{STYLEREF "Heading 1" \l} > {STYLEREF "Heading 2" \l} > {STYLEREF "Heading
3" \l} > {STYLEREF "Heading 4" \l}
would show. So, for instance, on a page that shows
2.1.2 Test files
2.2 Output files
The heading shows
Source files > Output files > Test files > User interface
Where "Source files" is the prior heading 1 text and "User interface" is the
heading 4 text from several pages ahead in the document. So instead of
showing the text for heading level 2.1 (which is the parent of 2.1.2), I get
the text for heading level 2.2 as well as the text for 2.3.2.1.
After many hours/days of fiddling, I still can't figure out where I'm going
wrong.
Here's what my header code looks like:
{IF {STYLEREF "Heading 5" \n \l}={STYLEREF "breadcrumbs" \n \l}, "{STYLEREF
"Heading 1" \p \l} > {STYLEREF "Heading 2" \p \l} > {STYLEREF "Heading 3" \p
\l} > {STYLEREF "Heading 4" \p \l}" }
I found that if the Heading 5 above was a Heading 4, the entire header would
be blank for any pages where a Heading 4 actually appeared--is this right?
Using a lower-level heading (i.e. one that I didn't wish to display in the
header) seemed to work around this behavior.
Any suggestions you might have are most appreciated.
BTW, in your original post, there was a tiny but vital comma omitted from
your code (between the if/then part of the code)--it took me a while to
figure out the problem.
--
Susan
Technical Writer
Here's what my code has evolved to: {StyleRef 1 \n \l} {StyleRef 1 \p
\l} {IF {StyleRef 2 \n \l } = {StyleRef HeadChar \n \l } " > {StyleRef
2 \n \l } {StyleRef 2 \p \l }"{IF {StyleRef 3 \n \l } = {StyleRef
HeadChar \n \l } " > {StyleRef 2 \n \l } {StyleRef 2 \p \l } >
{StyleRef 3 \n \l } {StyleRef 3 \p \l }" [etc.]
You don't need the quotation marks within the StyleRef codes unless the
style has a space in it (like "Heading 1") --- and StyleRef recognises
a number as a heading level ('StyleRef 2' is the same as 'StyleRef
"Heading 2"'). Also, you don't need the comma in the IF-THEN
construction; the quotation marks are enough to indicate where the THEN
starts. And I realised I always want H1, so I only add the
conditionals for H2 onward.
I can't explain the anomalies you're getting... What version of Word
are you using (I've got 2003)? The tricky thing I've found is to make
sure that everything you want tagged the dummy character format
(HeadChar for me or Breadcrumbs for you) is tagged as such, and that
nothing that shouldn't be isn't. The best way to do this is to search
down for paragraphs tagged HeadChar (or Breadcrumbs).
I've also found that sometimes it doesn't work for some unknown reason
when a heading paragraph breaks over a page. Similar (I think) to what
you discovered, the workaround for me is to add a heading level below
it, eg if the 'page-broken' heading is level 2 to add a carriage return
at the end of the page, format it H3, and backspace over the numbering.
Hope that helps!
Cheers,
jh
Hope that helps!
Cheers,
jh
Hope that helps!
Cheers,
jh