You have the right idea, but the wrong approach. Try:
Code:
Sub TagtoStyle()
Application.ScreenUpdating = False
Dim rngStory As Range, StrStry As String
For Each rngStory In ActiveDocument.StoryRanges
With rngStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "\<[! ]@\>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
If .Find.Found = False Then
Select Case rngStory
Case wdCommentsStory: StrStry = "Comments"
Case wdEndnotesStory: StrStry = "Endnotes"
Case wdFootnotesStory: StrStry = "Footnotes"
Case wdMainTextStory: StrStry = "Document Body"
Case Else: StrStry = ""
End Select
If StrStry <> "" Then MsgBox "No tags found in: " & StrStry, vbExclamation
End If
Do While .Find.Found = True
.Style = Split(Split(.Text, "<")(1), ">")(0)
.Text = vbNullString
.Find.Execute
Loop
End With
Next rngStory
Application.ScreenUpdating = True
End Sub
Note that a slightly different approach is needed to include all headers & footers in a multi-section document.