There are basically two ways of processing all headers/footers in a document. The following two subs demonstrate them.
The first sub loops through all sections, then through all headers/footers in the section, testing whether they're linked to a previous one.
The second sub achieves the same result more simply and more efficiently, without the need to check the LinkToPrevious state, by processing the corresponding story-ranges.
There are, of course, advantages to the first approach in some situations.
Sub Demo1()
Application.ScreenUpdating = False
Dim Fld As Field, Sctn As Section, HdFt As HeaderFooter
With ActiveDocument
For Each Sctn In .Sections
For Each HdFt In Sctn.Headers
With HdFt
If .LinkToPrevious = False Then
With .Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.Text = ""
.Replacement.Text = ""
.MatchCase = True
.MatchAllWordForms = True
.MatchWholeWord = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
End If
End With
Next
For Each HdFt In Sctn.Footers
With HdFt
If .LinkToPrevious = False Then
With .Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.Text = ""
.Replacement.Text = ""
.MatchCase = True
.MatchAllWordForms = True
.MatchWholeWord = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
End If
End With
Next
Next
End With
End Sub
Sub Demo2()
Dim Stry As Range
With ActiveDocument
For Each Stry In .StoryRanges
With Stry
Select Case .StoryType
Case wdEvenPagesHeaderStory, wdFirstPageHeaderStory, wdPrimaryHeaderStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.Text = ""
.Replacement.Text = ""
.MatchCase = True
.MatchAllWordForms = True
.MatchWholeWord = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
Case wdEvenPagesFooterStory, wdFirstPageFooterStory, wdPrimaryFooterStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.Text = ""
.Replacement.Text = ""
.MatchCase = True
.MatchAllWordForms = True
.MatchWholeWord = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
End Select
End With
Next
End With
End Sub
I too would prefer not to entangle myself in yet another attempt to (mis)use Word as an HTML editor.