I have a document that has 2 Headers in it that Word Identifies as "First Page Header", and "Header". The FPH is the same as the Header, except that it contains a graphic. The document is 7 pages long. Immediately after loading the document, I activate the macro recorder and do the following:
[red]
Ctrl-End
View Header/Footer
Click "Same as Previous" button
(Deactivating SaP for the header)
Ctrl-A
Delete
Author Index
Ctrl-A
Click Bold / Center / Bottom Border
Close Header/Footer ToolBar
[/red]
...and then stop recording.
The document looks perfect. An 8th page has been added with a header that says "Author Index". The first 7 pages are all the way they should be.
I then close the document without saving it, then re-open it. I then run the macro, and the results are just plain weird.
The Author Index header is at the top of Page 1. The header with the graphic is on page 8. Obviously, that is exactly the opposite of what should happen.
The recorded code follows. Answers/suggestions would be greatly appreciated.
[red]
Ctrl-End
View Header/Footer
Click "Same as Previous" button
(Deactivating SaP for the header)
Ctrl-A
Delete
Author Index
Ctrl-A
Click Bold / Center / Bottom Border
Close Header/Footer ToolBar
[/red]
...and then stop recording.
The document looks perfect. An 8th page has been added with a header that says "Author Index". The first 7 pages are all the way they should be.
I then close the document without saving it, then re-open it. I then run the macro, and the results are just plain weird.
The Author Index header is at the top of Page 1. The header with the graphic is on page 8. Obviously, that is exactly the opposite of what should happen.
The recorded code follows. Answers/suggestions would be greatly appreciated.
Code:
Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakNextPage
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
LinkToPrevious
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Author Index"
Selection.WholeStory
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
With Selection.Borders(wdBorderBottom)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument