TOC showing number of pages in each section

C

Compass Rose

Using Word 2007

I have a document with 20 chapters, and the end of each chapter has a Next
Page Section Break. I also have a TOC, but instead of the TOC showing the
starting page number of each chapter, I want it to show the {SECTIONPAGES}
field for that chapter. Is this possible?

TIA

David
 
S

Stefan Blom

Where in the TOC do you want the number of pages in the section?

If you are saying that you want something like this:

1 Section 1
(Number of pages in section one: X)
1.1 First sub-section..................................................7

2 Section 2
(Number of pages in section two: Y)
2.1 First sub-section.................................................15

that is, the page count being a separate entry in the table of contents, you
can make use of TC fields. These fields won't show in the body of the
document.
 
C

Compass Rose

I'm not sure if we're on the same page. What I want looks like this:

Chapter 1 .........................5 ({SECTIONPAGES} of section 1)
Chapter 2 .........................3 ({SECTIONPAGES} of section 2)
Chapter 3 .........................3 ({SECTIONPAGES} of section 3)
etc.

How would the TC field give this result?

David
 
D

Doug Robbins - Word MVP

You cannot do it by use of the Table of Contents facility.

It would be possible to use a macro to build such a list.

Assuming that Chapter 1 starts in Section 2 of the document and that at the
location of the selection, you format a paragraph with the necessary tab
right aligned tab stop with a dot leader, if you run a macro containing the
following code, it would create the list that you require:

Dim i As Long, j As Long

j = Selection.Sections(1).Range.Information(wdActiveEndPageNumber)
With ActiveDocument
For i = 2 To .Sections.Count
Selection.Range.InsertAfter "Chapter " & i - 1 & vbTab &
..Sections(i).Range.Information(wdActiveEndPageNumber) - j & vbCr
Selection.MoveDown wdParagraph, 1
j = .Sections(i).Range.Information(wdActiveEndPageNumber)
Next i
End With


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
C

Compass Rose

Thank you, Doug

I'm assuming that if I edit the document that results in a change in the
number of pages in a section, I would have to re-run the macro.

I had another thought. In each section, I could assigned a bookmark to the
{SECTIONPAGES} field, such as {SET sectionpages1 {SECTIONPAGES}}. I could
then manually set up my "TOC" with the Chapter name, your right aligned tab
stop with dot leader, and then {REF sectionpages1}. Would this work? Would
it update automatically if I did a Print Preview?

Thanks,
David
 
D

Doug Robbins - Word MVP

Yes, you would have to delete the list previously created by the macro and
then run it again.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
D

Doug Robbins - Word MVP

Yes, I think that the other method that you thought of would work. You will
need to be careful that your {SET sectionpages1 {SECTIONPAGES}} field
constructions do not get deleted however as without field codes toggled on,
there is nothing to be seen.

Assuming that you have SectionPages fields in the footer/header of each
section, it might be better to just apply the bookmarks manually to those
fields.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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