How to add custom text to the Footer?

S

Sandusky

Windows XP Pro SP3
MS Office 2002 SP3

I have a document that is basically a novel. The document is set up
so that every chapter is it's own Section, set off by Section Breaks
(Next Page) for each chapter. There are a few additional Section
Breaks (Next Page) besides those for Chapters, i.e. a Table of
Contents, an Afterwords and a Glossary of Terms. The ONLY section
breaks used were of the Section Break (Next Page) variety. The page
setup is mirror margins, 1 inch for the top and bottom, 2.2 inches for
the Inside and 0.7 inches for the Outside

What I'd like to do as add text to the footer, aligned to the Inside,
with the text values based on what range of section numbers that page
is in. For example, for sections 1 to 10, use "This value", for
sections 11 to 14 use "This other value", and so on.

I was trying to accomplish by looping through the document sections.
Inside the loop I create/calculate a text variable depending on the
section number like I described above. It was my original thought to
drop the variable text value into a a field that I would insert into
the footer, but I couldn't figure how to do that. Could somebody
explain to me how to do that, if possible? Or, is there another way
to do this without using fields? Any and all help and suggestions
would be greatly appreciated.

NOTE: basically what I'm asking for is another way to put the Chapter
number/name in the footer, but doing that through the Bullets and
Numbering format menu yielded very undesirable results.
 
P

Pesach Shelnitz

Hi,

To achieve "inside alignment" use different footers for even and odd pages
and right- or left-justify the footer content in each type of footer
accordingly. This should be straightforward.

You can use field codes to achieve the specific footers that you want in
each section while using the same footers in all the sections. Since you want
to have different text, depending on whether the footer is in a section with
a number less than 11 or not, you can use the IF field, as in the following
example.

{IF 11 > {SECTION} "{STYLEREF "Heading 1"}" "This other value"}

To create this field, copy the preceding line into a footer and delete all
the curly brackets ({}). Then separately block the text that was enclosed in
each pair of curly brackets and press Ctrl+F9. At this point the field code
should look like the line above again. Now move the cursor to the word IF,
press F9 and then press Alt+F9. Of course, you can modify my example to
include other text and other fields.
 
S

Sandusky

Thanks Pesach, that does help me quite a bit conceptually. However,
I'll need to do this via a macro, so I guess I'll need to know how to
edit the footer expression via VBA.
 
P

Pesach Shelnitz

Hi,

This can all be done via VBA, but I suggest that you first create the field
codes in the footers manually to be sure of the result that you want to
acheive.

To get you started with the coding, I can offer the following. You will need
to modify this if you want a different footer on the first page of each
section.

Dim i As Integer
With ActiveDocument
.PageSetup.DifferentFirstPageHeaderFooter = False
.PageSetup.OddAndEvenPagesHeaderFooter = True
For i = 2 To .Sections.Count
.Sections(i).Footers(wdHeaderFooterPrimary).LinkToPrevious = True
.Sections(i).Footers(wdHeaderFooterEvenPages).LinkToPrevious =
True
Next
End With

After you get this part the way you want it, you need to work with the
Section(1).Footers collection to add the text and field codes that you want.

The basic procedure for creating the field codes is to use, for example, the
..Sections(1).Footers(wdHeaderFooterEvenPages).Range.Fields.Add method to
create an empty field, set its code, and add the appropriate text to it. Then
create the nested fields by moving the insertion point (Selection object) to
the appropriate place and adding another empty field, etc.

Write back with more details if you need more help.
 

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