Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page numbers by section and overall 3

Status
Not open for further replies.

-cush-

Programmer
Feb 18, 2004
145
US
I have a word document of policy and procedures. Each chapter is broken into sections with it's own footers. It seems easy enough to add page numbers for the overall document or to be able to create page numbers that start over in each section. However I want to do both. Is it possible? I want the footer to look something like the following

Adopted: [date] Running Page #25 Policy Name - Page 1 of 6
 
Not saying this'll have the answer for you, but it sounds like it could at least be helpful:

I'd think it possible if you just find and use the correct codes and setup a custom footer. I've never done it, but it definitely seems to likely be possible.


"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Regret, this isn't easy at all - although it is a common enough requirement that it should be. As a one-off exercise after editing, you can hard code the numbers you want, which looks like what you are doing - but you will have to re-do it every time you edit the document.

There is no easy way to automate the whole thing. It needs some painstaking messing with different headers and footers in each section. You need to calculate - separately in each section - the running total of pages prior to that section so that you can use that figure in separate calculations in each section and this means you need to have different footers (assuming your page numbers are in the footer) in each section, with almost the same content.

It can be done but it isn't fun!


Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Agreed Tony! I was surprised that there wasn't a way to permanently set these footers without having to change them when an additional page is created or removed. Since there is a way to reset the page numbers at the start of each section and there is a way to keep then sequential throughout the document, why not create a way to do both. One should be able to create their own running total variable that can be changed by function at the beginning of each section, page, column, etc. to whatever end one chooses.
 
Even if there were more auto macros that fired when at the start of each section etc, it could be done. But so far the only auto macros are:

AutoExec (When you start Word or load a global template)
AutoNew (Each time you create a new document)
AutoOpen (Each time you open an existing document)
AutoClose (Each time you close a document)
AutoExit (When you exit Word or unload a global template)
 
As you have already got separate footers (assuming your page numbers are in the footer), you can automate this further by doing something along these lines ...

In the footer for section 1 ...

[blue][red][tt]{[/tt][/red][tt] Set PagesBeforeSect[/tt][red][tt]1[/tt][/red][tt] 0 [/tt][red][tt]}[/tt][/red][/blue][tt] [/tt][red][tt]{[/tt][/red][tt] Set PagesBeforeSect[/tt][red][tt]2[/tt][/red][tt] [/tt][red][tt]{[/tt][/red][tt] =([/tt][red][tt]{[/tt][/red][tt] PagesBeforeSect[/tt][red][tt]1[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][tt] + [/tt][red][tt]{[/tt][/red][tt] SectionPages [/tt][red][tt]}[/tt][/red][tt]) [/tt][red][tt]}[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][tt]
Page [/tt][red][tt]{[/tt][/red][tt] Page [/tt][red][tt]}[/tt][/red][tt] of [/tt][red][tt]{[/tt][/red][tt] NumPages [/tt][red][tt]}[/tt][/red][tt] Section Page [/tt][red][tt]{[/tt][/red][tt] =([/tt][red][tt]{[/tt][/red][tt] Page [/tt][red][tt]}[/tt][/red][blue][tt]-[/tt][red][tt]{[/tt][/red][tt] PagesBeforeSect[/tt][red][tt]1[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][/blue][tt]) [/tt][red][tt]}[/tt][/red][tt] of [/tt][red][tt]{[/tt][/red][tt] SectionPages[/tt][red][tt]}[/tt][/red][tt][/tt]

... in the footer for section 2 ...

[red][tt]{[/tt][/red][tt] Set PagesBeforeSect[/tt][red][tt]3[/tt][/red][tt] [/tt][red][tt]{[/tt][/red][tt] =([/tt][red][tt]{[/tt][/red][tt] PagesBeforeSect[/tt][red][tt]2[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][tt] + [/tt][red][tt]{[/tt][/red][tt] SectionPages [/tt][red][tt]}[/tt][/red][tt]) [/tt][red][tt]}[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][tt]
Page [/tt][red][tt]{[/tt][/red][tt] Page [/tt][red][tt]}[/tt][/red][tt] of [/tt][red][tt]{[/tt][/red][tt] NumPages [/tt][red][tt]}[/tt][/red][tt] Section Page [/tt][red][tt]{[/tt][/red][tt] =([/tt][red][tt]{[/tt][/red][tt] Page [/tt][red][tt]}[/tt][/red][tt]-[/tt][red][tt]{[/tt][/red][tt] PagesBeforeSect[/tt][red][tt]2[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][tt]) [/tt][red][tt]}[/tt][/red][tt] of [/tt][red][tt]{[/tt][/red][tt] SectionPages[/tt][red][tt]}[/tt][/red][tt][/tt]

... in the footer for section 3 ...

[red][tt]{[/tt][/red][tt] Set PagesBeforeSect[/tt][red][tt]4[/tt][/red][tt] [/tt][red][tt]{[/tt][/red][tt] =([/tt][red][tt]{[/tt][/red][tt] PagesBeforeSect[/tt][red][tt]3[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][tt] + [/tt][red][tt]{[/tt][/red][tt] SectionPages [/tt][red][tt]}[/tt][/red][tt]) [/tt][red][tt]}[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][tt]
Page [/tt][red][tt]{[/tt][/red][tt] Page [/tt][red][tt]}[/tt][/red][tt] of [/tt][red][tt]{[/tt][/red][tt] NumPages [/tt][red][tt]}[/tt][/red][tt] Section Page [/tt][red][tt]{[/tt][/red][tt] =([/tt][red][tt]{[/tt][/red][tt] Page [/tt][red][tt]}[/tt][/red][tt]-[/tt][red][tt]{[/tt][/red][tt] PagesBeforeSect[/tt][red][tt]3[/tt][/red][tt] [/tt][red][tt]}[/tt][/red][tt]) [/tt][red][tt]}[/tt][/red][tt] of [/tt][red][tt]{[/tt][/red][tt] SectionPages[/tt][red][tt]}[/tt][/red][tt][/tt]

etc., etc.

The bits to note are the red braces, which are field delimiters entered, in pairs, via Ctrl+F9 and the red numbers, in which I hope you can see the pattern.

The bits in blue italics, setting and using, "PagesBeforeSect1" aren't strictly necessary but they make the whole thing more consistent.

This kind of stuff is very fiddly and you have to get it exactly right, but when you do you shouldn't have to make any more changes unless you want to add or remove extra sections.

I have experimented with using dynamic variable names but never got it to work consistently as I wished - maybe one day I'll be confident to post a version like that, but not today [smile]



Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top