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