View Single Post
 
Old 04-01-2014, 05:57 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote