wdHeaderFooterFirstPage, wdHeaderFooterPrimary or wdHeaderFooterEvenPages

S

Senad Isanovic

How do I loop through all sections in the doc and set range variable to
footer range wdHeaderFooterFirstPage, wdHeaderFooterPrimary, or
wdHeaderFooterEvenPages. I also need to know that exactly is the difference
between those three constants



If ActiveDocument.Sections.PageSetup.DifferentFirstPageHeaderFooter Then

Set rgeFooter =
sSec1.Footers(wdHeaderFooterFirstPage).Range.Paragraphs(1).Range

Else

Set rgeFooter =
sSec1.Footers(wdHeaderFooterPrimary).Range.Paragraphs(1).Range

End If
 
D

Doug Robbins - Word MVP

Each Section of a document can have three Headers and three Footers.

1 The First Page Header/Footer is the one that will appear on the first
page of the document if in Page Layout (or programmatically) the Section is
set up to have a Different First Page

2 The Primary Header/Footer is the one that will appear:

(a) On all pages if the Section is not set to have a Different First Page
or Different Odd and Even

(b) On the other pages if the Section is set to have a Different First
Page and it is not set to have Different Odd and Even

(c) On the other Odd pages if the Section is set to have a Different
First Page and to have Different Odd and Even

3 The Even Header/Footer will appear on the Even pages of a section that
is set to have Different Odd and Even.

To do something with the .Range of all of the possible headers and footers
in all of the sections of a document, you would need to use:

Dim i As Long
Dim myrange As Range
With ActiveDocument
For i = 1 To .Sections.Count
With .Sections(i)
Set myrange = .Headers(wdHeaderFooterFirstPage).Range
'do something with myrange
Set myrange = .Footers(wdHeaderFooterFirstPage).Range
'do something with myrange
Set myrange = .Headers(wdHeaderFooterPrimary).Range
'do something with myrange
Set myrange = .Footers(wdHeaderFooterPrimary).Range
'do something with myrange
Set myrange = .Headers(wdHeaderFooterEvenPages).Range
'do something with myrange
Set myrange = .Footers(wdHeaderFooterEvenPages).Range
'do something with myrange
End With
Next i
End With

--
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
 
E

edwinf

Mr. Doug Robbins,
I am also new to this programming. I have some details to know
regarding your reply...Where in the part will i put the codes you gave? And
could you please give me a sample on what to put after you set "myrange"
value? Like,

Set myrange = .Headers(wdHeaderFooterFirstPage).Range
'do something with myrange <--- on this part?

Because i have this problem on how to put a certain fix table for
every page (with page 1 differ from the next pages)... You can see my Post
titled "How to loop a certain header with a certain condition"
I've titled this as header bec. i can't figured out where to put that
looping table.
Please let me have your help...
Thanks in advance....
 

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