Variable Footers

A

AJ

I need a way to create different footers for every page. Let's say the
document is 5 pages long. The user is prompted as to how to start the
numbering series. They will answer with a number only, say 3. The sequence
follows such that page 1's footer displays 3 right-aligned. Page 2's footer
would display 3A to left-aligned. Page 3's footer would display 3B
right-aligned, and so goes the series for every page with incrementing
letters and alternating alignments. Since I can't seem to control footers on
an individual basis programmatically without sections interfering, what
should I do? A couple things I've thought of are 1) making each page its own
section, 2) inserting a docvariable field into each footer, then updating the
field value with the correct page number. I am an experienced .NET/VBA
developer but working with Word's sections is not intuitive for me. I will
process documents that are generated out of my control, and I expect these
documents to have one section for the entire document. I would greatly
appreciate a recommended programmatic approach. Feel free to be very
technical. Thanks !
 
L

Lisa

Not sure if this will help, but you might want to consider setting the page
number style to "wdPageNumberStyleUppercaseLetter".

If you want all pages in the doc numbered with the number that the user
specifies followed by "A" (for second page), "B" (for third page), etc. it
seems you'd need only two sections.

The first section contains only the first page. The footer on that page does
not include an actual page number -- just the number that the user entered.

The second section contains all pages except the first page. Pages in
Section 2 would have the number the user entered, plus an actual page number
(which is displayed as an uppercase letter).
 
L

Lisa

Forgot to mention, you'd need to specify that Section 2 would also need to be
specified to restart number at 1...

With ActiveDocument.Sections(2).Footers(wdHeaderFooterPrimary).PageNumbers
.NumberStyle = wdPageNumberStyleUppercaseLetter
.RestartNumberingAtSection = True
.StartingNumber = 1
End With
 
A

AJ

Lisa:

Thanks for your replies! I do understand it a bit better and enlisted the
help of a co-worker that understands how sections work. My plan is to insert
the requested page number from the user into the first page footer. Then, I
believe I need to create a new section at the end of the first page. The
second section that you mentioned is the one to which I wish to apply the
custom number formatting (3a, 3b, etc.) I think this is correct.

My only problem is that I can't determine how to find the end of a page.
When I find the end of a page, i.e. the last character on the first page, I
think I need to insert a new continuous section break to restart the
numbering for my custom format. Is this assertion true? If so, how do I
find the end of a page? Thanks!
 
L

Lisa

Here's an approach to inserting a section break at the end of a first page in
a document... I'm guessing that there's a better way, but this seems to work:
Dim totpg As Integer
totpg = Selection.Information(wdNumberOfPagesInDocument)
If totpg >= 2 Then
With Selection
.GoTo What:=wdGoToPage, Count:=2
.InsertBreak Type:=wdSectionBreakNextPage
End With
Else 'if only one page, go to end
Selection.EndKey Unit:=wdStory
End If
 
A

AJ

I actually got the solution nailed right after I posted today. I did end up
using just the one default section, and manipulating the available first,
odd, and even footers to my own end. However, you got me thinking more about
working with sections. Thanks again Lisa!
 

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