Question about TOC position and footer

G

Grenier

Automating a word report. the TOC can take the space of 1 to 3 pages long.
I'm looking for the correct way to insert the TOC on page 3 of the report.

When I build the report, I leave page 3 empty (sectionbreak in top of page)
, set all the toc field in the following pages and once done, I return or
goto page 3 and then add the TOC. The problem that I have is with the footer
of pages containing the TOC. If the TOC has just one page, the footer is OK.
If the TOC has 2 or more pages, the footer is not repeated. (probably because
no section break ?) here's the step I coded...

..DifferentFirstPageHeaderFooter = True
page1 :no footer
page2 :add custum footer, wdHeaderFooterFirstPage, LinkToPrevious=false
page3 : insert TOC, wdHeaderFooterPrimary, LinkToPrevious=true
...suppose toc is 3 pages long
page4 : no footer
page5 : no footer
page6 : add custum footer, wdHeaderFooterFirstPage, LinkToPrevious=false OK

How can I get a footer on page 4 and 5. Can I force footer to appear on each
page instead of each section cause the problem here is that the section is 3
pages long.
Maybe it's not the way to do it ? and hoping I'm clear...

Merci !
 
F

fumei via OfficeKB.com

A bit more clarity may help.

Why are you making DifferentFirstPage? If the TOC is in its own Section - a
good idea - then just put the footer for it, into it. Whether it is 1 page,
or 3 pages, or 4 pages, they will all have the same footer. For example:



Sub MyToCMarker()
Dim oHF As HeaderFooter
Dim var
With Selection
.HomeKey Unit:=wdStory
.InsertBreak Type:=wdSectionBreakNextPage
.MoveLeft Unit:=wdCharacter, Count:=1
ActiveDocument.Bookmarks.Add Name:="ToC_Here", _
Range:=Selection.Range
For var = 1 To 3
Set oHF = ActiveDocument.Sections(2).Footers(var)
oHF.LinkToPrevious = False
Next
.Sections(1).Footers(wdHeaderFooterPrimary).Range _
.Text = "This is ToC footer"
End With
End Sub

Sub MakeMyToC()
Selection.GoTo What:=wdGoToBookmark, Name:="ToC_Here"
With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range, _
RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
LowerHeadingLevel:=3, IncludePageNumbers:=True, _
AddedStyles:="", _
UseHyperlinks:=True, HidePageNumbersInWeb:=True, _
UseOutlineLevels:=True
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With
End Sub

What these do.

Sub MyToCMarker()
goes to the start of the document
makes a Section break
backs into the Section it just made
adds a bookmark (to mark where the ToC is going to go)
makes all the footer of the NEXT Section (the one now AFTER the TOC Section)
LinkToPrevious = False. This ensures any EXISTING footers remain correct.
adds the text for the TOC footer

Sub MakeMyToC()
goes to the bookmark where you want the ToC
makes the ToC - note: default parameters used

Now you can make the ToC Section on its own, and when you ready...make the
ToC.

Again, it makes no difference if the the ToC is 1 page...or expands to 123
pages. The ToC section will its own footer.
 
J

Jean-Guy Marcil

Grenier said:
Automating a word report. the TOC can take the space of 1 to 3 pages long.
I'm looking for the correct way to insert the TOC on page 3 of the report.

When I build the report, I leave page 3 empty (sectionbreak in top of page)
, set all the toc field in the following pages and once done, I return or
goto page 3 and then add the TOC. The problem that I have is with the footer
of pages containing the TOC. If the TOC has just one page, the footer is OK.
If the TOC has 2 or more pages, the footer is not repeated. (probably because
no section break ?) here's the step I coded...

.DifferentFirstPageHeaderFooter = True
page1 :no footer
page2 :add custum footer, wdHeaderFooterFirstPage, LinkToPrevious=false
page3 : insert TOC, wdHeaderFooterPrimary, LinkToPrevious=true
...suppose toc is 3 pages long
page4 : no footer
page5 : no footer
page6 : add custum footer, wdHeaderFooterFirstPage, LinkToPrevious=false OK

How can I get a footer on page 4 and 5. Can I force footer to appear on each
page instead of each section cause the problem here is that the section is 3
pages long.
Maybe it's not the way to do it ? and hoping I'm clear...

It looks as though you are using a TOC section that is preceded by 2
sections. Each of the first two sections have only one page, but are using
the "First Page Different" footer/header setting? Why?
If you have only one page in a section and do not intend to have more pages
in those sections (or do not need a different first page footer), do not use
that setting. As is, when you add page 2 and following in the third section
(TOC), Word uses the section 3 primary footer, which by default is linked to
the one from the previous section (Even if the First page footer is not
linked, the primary one can be, and will be by default until you set it
otherwise).
Now, because (I guess) you have never set the primary footer in sections 1
and 2, the primary footer in section 3 is empty becasue it is linked to an
empty primary footer. The easiest way out of your "predicament", is to go
back and redefine your approach.
Sections 1, 2 and 3 do not need a "First Page Different" setting. Remove
that setting from the first three sections, use only the primary footer,
unlink them all and set the content as you do now. From section 4 onward, if
you have Chapter Tile pages (or something similar) then you may use a "First
Page Different" setting, otherwise, don't!

Alternatively, you could eliminate section 2 and place the TOC in section 2.
Section 1 would be two-page long. Now you could use "First Page Different" in
section 1, but not in 2. Keep the first page footer in section 1 empty, the
first primary footer in section 1 as you wish. Then, in section 2 (TOC), do
not use the "First Page Different" setting and unlink the primary footer
before setting the content as you wish. Your document would start in section
three, also with its footers unlinked, I guess.

Too often I have wasted hours reformatting a 200-300 hundred-page document
that was all messed up because section breaks had been inserted willy-nilly,
and First Page/Odd-Even Different was used for no valid eason, making the
management of the editing atrocious... Don't create a future headache by
using settings that you do not need.

As the saying goes, K.I.S.S., no, not the rock band or an emotional
response... Keep It Short and Simple.
 
G

Grenier

You guys were right !
I removed .DifferentFirstPageHeaderFooter, use primary footer and everything
is running smooth !

Got to understand the use of DifferentFirstPageHeaderFooter.

Thank' again !
Merci encore !
Jean-Francois Grenier
 

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