The basic tagging can be done with Find/Replace code like:
Code:
Sub TagHeadings()
Dim i As Long
For i = 1 To 9
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchWildcards = False
.Style = "Heading " & i
.Execute
End With
Do While .Find.Found
.InsertBefore "<case>"
.Characters.Last.InsertBefore "</case>"
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Next
End Sub
As for printing somewhere else, there's no need to select anything. In the above code, for example, you could output each heading to another location by adding code within the Do While ... Loop. That would output the headings by level, not by order within the document. The simplest method for outputting them in order, is to add a Table of Contents to the document - right where you want them to appear.