insert page footer on every page

S

sals

Hi,

I have a document that consists of section and page breaks. I'm using
this code to insert a page number footer onto every page. But on the
pages where the content of the document goes to the bottom of the
page, the footer(page number) is not showing up.

Thanks in advance.
_______________________________________________________
Sub insertFooter()
Dim mySCTN As Section

For Each mySCTN In ActiveDocument.Sections
With ActiveDocument.Sections(mySCTN.Index).Footers _
(wdHeaderFooterPrimary)
.PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberRight
End With
Next mySCTN


End Sub
 
D

DA

Check your document page setup (ie. margins, and
especially the "Footer from edge" setting) to ensure that
the page number is not being pushed off the page.

The original code I provided you uses a text frame, which
shifts by default when other text infringes on it.

Alternatively, you can use the following, which doesn't
use the frame, although if your footer is not big enough,
this won't help either.

As I said, I'd focus on correct page setup.

Good luck,
Dennis

---------
Sub AddPageNo()
Dim mySCTN As Section

For Each mySCTN In ActiveDocument.Sections
With ActiveDocument.Sections(mySCTN.Index)
.Footers.Item(wdHeaderFooterPrimary).Range.Select
With Selection
.Fields.Add Range:=Selection.Range, Type:=wdFieldPage
.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
End With
Next mySCTN

End Sub
 
L

Lemon

Hi DA,

I tried adjusting the footer from edge property, the page number didnt' get displayed.

Allow me to provide you with the background....The pages in this document were inserted from other files(one or two pagers). Hence, some of them might appear to be the 'first page'.

But I noticed when I turned on the header/footer view, on some pages, it displayed "first page footer, section x" and on other "footer, section x".

The page number only appeared on the footer with solely "footer, section x" and not on "first page footer, section x".

what to do?

Thanks,

S
 
S

sals

thanks to all those who helped.
I changed my code to turn off differnt first page footer

Sub insertFooter()

Dim mySCTN As Section
For Each mySCTN In ActiveDocument.Sections
ActiveDocument.Sections(mySCTN.Index). _
PageSetup.DifferentFirstPageHeaderFooter = False
With ActiveDocument.Sections(mySCTN.Index)
.Footers(wdHeaderFooterPrimary).PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberRight, _
FirstPage:=True
End With
Next mySCTN

End Sub

now it works =)


___________________________
 
L

Lemon

thanks for your help DA
I changed my code to turn off differnt first page footer

Sub insertFooter()

Dim mySCTN As Section
For Each mySCTN In ActiveDocument.Sections
ActiveDocument.Sections(mySCTN.Index). _
PageSetup.DifferentFirstPageHeaderFooter = False
With ActiveDocument.Sections(mySCTN.Index)
.Footers(wdHeaderFooterPrimary).PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberRight, _
FirstPage:=True
End With
Next mySCTN

End Sub

now it works =)

___________________________
 

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