J
Julia T.
Hi,
I am trying to create a macro that will: 1) create a new
section at the end of the document for an envelope and 2)
discontinue the headers/footers in the previous sections.
When I do this as I am recording the macro, it works
great. However, when I run the macro it deletes the
footer in the first section of the document. I promise I
know how headers and footers work.
I have the following code:
Sub Test()
'
'THIS GOES TO THE END AND CREATES THE NEW SECTION
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.InsertBreak Type:=wdSectionBreakNextPage
'THIS CREATES A NEW BLANK HEADER AND FOOTER IN THE NEW
(LAST) SECTION
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter. _
LinkToPrevious
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
End If
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter. _
LinkToPrevious
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub
I would be gratefull for any ideas - I've been working for
days on this. . .
Thanks
I am trying to create a macro that will: 1) create a new
section at the end of the document for an envelope and 2)
discontinue the headers/footers in the previous sections.
When I do this as I am recording the macro, it works
great. However, when I run the macro it deletes the
footer in the first section of the document. I promise I
know how headers and footers work.
I have the following code:
Sub Test()
'
'THIS GOES TO THE END AND CREATES THE NEW SECTION
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.InsertBreak Type:=wdSectionBreakNextPage
'THIS CREATES A NEW BLANK HEADER AND FOOTER IN THE NEW
(LAST) SECTION
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter. _
LinkToPrevious
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
End If
Selection.HeaderFooter.LinkToPrevious = Not
Selection.HeaderFooter. _
LinkToPrevious
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub
I would be gratefull for any ideas - I've been working for
days on this. . .
Thanks