Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 04-01-2014, 05:57 AM
macropod's Avatar
macropod macropod is offline go to next heading, if there is one Windows 7 32bit go to next heading, if there is one 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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
go to next heading, if there is one How to add space between heading number and heading text Dr Wu Word 4 07-15-2018 03:52 AM
go to next heading, if there is one How to Restore Heading 1, Heading 2, etc. within a Word Document cheech1981 Word 9 01-11-2017 02:14 AM
go to next heading, if there is one Heading title before heading number johnor999 Word 4 12-06-2013 12:39 AM
Control the size of space between heading number and heading text Dr Wu Word 1 07-17-2013 12:24 PM
go to next heading, if there is one Styles: Heading 4 stuck at same heading number Hallet Word 1 05-31-2012 02:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft