Select each page ina documet and then change the header

C

cutecoder

Hi ,

I am trying to write a macro to insert/replace header and footer in a
document. In which goto do the following

step1: Select the page (in for loop)
step2: Check for multiple section of header and footer
step3: Replace/insert header and footer


could anyone please tell me how to select pages in sequence order?


Thank you
 
D

Doug Robbins - Word MVP

Headers and footers are associated with Sections, not pages. Therefore, it
is the Sections in a document that you need to cycle through

Dim i as long
With ActiveDocument
For i = 1 to .Sections.Count
With.Sections(i)
.Headers(wdHeaderFooterFirstPage).Range.Text =
.Headers(wdHeaderFooterPrimary).Range.Text =
.Footers(wdHeaderFooterFirstPage).Range.Text =
.Footers(wdHeaderFooterPrimary).Range.Text =
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
 
C

cutecoder via OfficeKB.com

Hi Doug Robbins,

thank you for your help it worked fine for me.

Regards
Headers and footers are associated with Sections, not pages. Therefore, it
is the Sections in a document that you need to cycle through

Dim i as long
With ActiveDocument
For i = 1 to .Sections.Count
With.Sections(i)
.Headers(wdHeaderFooterFirstPage).Range.Text =
.Headers(wdHeaderFooterPrimary).Range.Text =
.Footers(wdHeaderFooterFirstPage).Range.Text =
.Footers(wdHeaderFooterPrimary).Range.Text =
End With
Next i
End With
[quoted text clipped - 8 lines]
Thank you
 
Top