A
andreas
Hello,
I recently wrote a macro code that is setting up running headers (odd
and even) in long documents with several sections (all headers and
footers are not linked to previous).
The odd page headers show the text from the numbered heading 1 levels
and I achieved this by telling Word:
Set rng = sect.Headers(wdHeaderFooterPrimary).Range
rng.Fields.Add rng, Type:=wdFieldEmpty, Text:= _
"STYLEREF ""Heading 1"" \n "
rng.Collapse wdCollapseEnd
rng.Text = " "
rng.Collapse wdCollapseEnd
rng.Fields.Add rng, Type:=wdFieldEmpty, Text:= _
" STYLEREF ""Heading 1"" "
Now the even page headers show the text from the numbered heading 2
levels:
Set rng = sect.Headers(wdHeaderFooterEvenPages).Range
rng.Fields.Add rng, Type:=wdFieldEmpty, Text:= _
"STYLEREF ""Heading 2"" \n "
rng.Collapse wdCollapseEnd
rng.Text = " "
rng.Collapse wdCollapseEnd
rng.Fields.Add rng, Type:=wdFieldEmpty, Text:= _
" STYLEREF ""Heading 2"" "
The trouble is that there are a couple of sections that haven't!! got a
heading level 2 (just a heading level 1). In these sections, the above
macro code causes Word to insert the text from heading level 2 on even
page headers from the previous section.
Hence my question: How can I tell Word that whenever a section hasn't
got a heading level 2, all headers (odd and even) should show only the
text from the heading level 1
Help is appreciated.
thank you in advance.
I recently wrote a macro code that is setting up running headers (odd
and even) in long documents with several sections (all headers and
footers are not linked to previous).
The odd page headers show the text from the numbered heading 1 levels
and I achieved this by telling Word:
Set rng = sect.Headers(wdHeaderFooterPrimary).Range
rng.Fields.Add rng, Type:=wdFieldEmpty, Text:= _
"STYLEREF ""Heading 1"" \n "
rng.Collapse wdCollapseEnd
rng.Text = " "
rng.Collapse wdCollapseEnd
rng.Fields.Add rng, Type:=wdFieldEmpty, Text:= _
" STYLEREF ""Heading 1"" "
Now the even page headers show the text from the numbered heading 2
levels:
Set rng = sect.Headers(wdHeaderFooterEvenPages).Range
rng.Fields.Add rng, Type:=wdFieldEmpty, Text:= _
"STYLEREF ""Heading 2"" \n "
rng.Collapse wdCollapseEnd
rng.Text = " "
rng.Collapse wdCollapseEnd
rng.Fields.Add rng, Type:=wdFieldEmpty, Text:= _
" STYLEREF ""Heading 2"" "
The trouble is that there are a couple of sections that haven't!! got a
heading level 2 (just a heading level 1). In these sections, the above
macro code causes Word to insert the text from heading level 2 on even
page headers from the previous section.
Hence my question: How can I tell Word that whenever a section hasn't
got a heading level 2, all headers (odd and even) should show only the
text from the heading level 1
Help is appreciated.
thank you in advance.