Creating Table of Contects Based on Bookmarks

D

denilynn

Can I create a table of contents based on bookmarked text, or is giving the
heading/title of each section a style name the only way to create a table of
contents?
 
G

Graham Mayor

You could add a TC field to each bookmark - the following macro should do
that:

Sub TOCBookmarks()
Dim rBM As Range
Dim sText As String
With ActiveDocument
For i = 1 To .Bookmarks.Count
Set rBM = .Bookmarks(i).Range
sText = rBM.Text
sText = Chr(34) & sText & Chr(34)
rBM.Collapse wdCollapseEnd
.Fields.Add rBM, wdFieldTOCEntry, sText, False
Next i
End With
End Sub

Then create a TOC from the TC fields.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top