PDA

View Full Version : Problems with Header/Footer after inserting a file



cmac
10-27-2005, 10:28 PM
Greetings,

I have a template that when i insert certain files that already have a header or footer insert themselves and override my document. Im not very experienced with either the header or footer part of a word document so please pardon my laim attempts.

Here is the process.

The user inserts a file.

Later on the user runs code to get rid of any header or footer information.

Sub KillHeadersFooters()
Dim oSection As Section
Dim oHeadFoot As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oHeadFoot In oSection.Footers
If Not oHeadFoot.LinkToPrevious Then oHeadFoot.Range.Delete
Next
Next
For Each oSection In ActiveDocument.Sections
For Each oHeadFoot In oSection.Headers
If Not oHeadFoot.LinkToPrevious Then oHeadFoot.Range.Delete
Next
Next

End Sub

Then I try and have the user run this code to reinsert page numbers into the entire document

Sub InsertPageNum()
Selection.Sections(1).Footers(1).PageNumbers.Add PageNumberAlignment:= _
wdAlignPageNumberCenter, FirstPage:=False
End Sub

But nothing happens to the document.

Please help

:help

fumei
10-28-2005, 07:38 AM
Does the document (with the inserted file) only have one section?

Does anything have Different first page, or Different Odd/Even header or footer?

cmac
10-28-2005, 08:07 AM
To be truthfull im not sure. When i do a search on the document that is problematic i find only one. And its at the top of the page.

Why is it when i use the above code that i can no longer either manually or VBA insert another page number at the bottom of my doc?

Thoughts?

fumei
10-29-2005, 07:04 AM
Huh? At the top of the page???? Uh, what were you searching for? I am not sure what you found.

Your code for insert page number has FirstPage = False. This is an explicit nstruction to NOT use page numbering on the first page.

How many pages are in the document?

Please check File > Page Setup and check for Different first page, Different Odd/Even.

Do you have Show/Hide ON? If not, please turn it on, and then look for Section breaks.

I can certainly manually put in page numbers.