glencoe,
Of course I won't argue if you code is working for you. Here is didn't work with the tags defined:
Tag1 = "##"
Tag2 = "**"
When I changed that to:
Tag1 = "##"
Tag2 = "##"
It still did nothing. Then I changed:
TempPrev = 1
to:
TempPrev = 0
and I had "mixed" results, but at least something happened.
Now looking at the example you have just provided, something like this works (for that example):
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oSection As Section
Dim oHF As HeaderFooter
Dim oRng As Range, oTextRng As Range
Dim strTag As String
strTag = "##"
For Each oSection In ActiveDocument.Sections
For Each oHF In oSection.Headers
With oHF
If .LinkToPrevious = False Or oSection.Index = 1 Then
Set oRng = oHF.Range
With oRng.Find
.Text = "(" & strTag & ")(*)(" & strTag & ")"
.MatchWildcards = True
.Replacement.Text = "\2"
While .Execute(Replace:=wdReplaceOne)
oRng.HighlightColorIndex = wdBrightGreen
oRng.Collapse wdCollapseEnd
Wend
End With
End If
End With
Next oHF
Next oSection
End Sub