Programmatically addressing headers/footers

L

Lighthouse

How can I create a macro that makes changes to headers automatically?
There's more. I have some Word documents that are generated by another
application. There are basically two categories of documents: those
with appendices and those w/o.

The application that creates the Word files can't handle the appendices
properly so my template uses a macro to fix them.

The macro looks for a certain style that has the text string "Appendix"
in it and if it exists it exchanges Heading1/2/3 styles for new
appendix-appropriate styles.

All this works fine so far. My remaining issue is that the template's
header is defined to pick up the last Heading 2 style in the chapter
and once I get into the appendices there are no Heading 2s, only
AHead2s. That means that my headers in the appendices display the last
Heading 2 from the section before where the appendices start. Did I
lose you yet?

Each chapter and each appendix is a new Word section and the headers
are different first page (no header) and odd and even header.

To fix this manually, I go to the last appendix in the book, get into
the header. If there are more than one appendix then I do a "same as
previous" all the way back to the second appendix. I need to do this
for each even and odd header. then I insert the proper field codes and
viola everything looks great.

How do I do this programmatically? How do I get into the odd and even
headers? What if a document has some 1 page appendices or 2 page
appendices (not all the headers are there). how do I handle the "same
as previous" thing for different numbers of existing appendices?

I'm vaguely aware of some "Story" object that probably identifies my
headers some way. The headers will already have existing field codes
that should be replaced by the new field codes. One field code inserts
a StyleRef para no. and the ohter field code inserts the StyleRef text.
Can my macro recognize which is which for proper substitution?

I know I'm asking a lot here, but I'm hoping that someone can point me
in the right direction. TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top