I have the following code which is supposed to loop through my document, find my Heading 9 paragraphs and then pick up the section number, copy the first pager header to that section and then loop to the next Heading 9 in the document.
My problem is that it isn't looping - it seems to be stuck wanting to do the same Heading 9 the entire time. I see that when I loop through the code. If I run it - it hangs Word, obviously because it is stuck in the loop.
Private Sub ReplaceAppendixCoverPages()
'goto each heading 9
'make sure the page is a first page header
'get the section number
'replace the header with the cover page header
Set Thisdoc = ActiveDocument
Dim myRange As Range
Dim n As Integer
.Style = ("Heading 9")
Do While .Execute(Forward:=True, Format:=True) = True
Set myRange = Selection.Range
n = myRange.Information(wdActiveEndSectionNumber)
Thisdoc.Sections(n).PageSetup.DifferentFirstPageHeaderFooter = True