Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Specifying a Table of Contents Entry.

Specifying a Table of Contents Entry

by Allen Wyatt
(last updated March 29, 2014)

4

If you are creating a regular table of contents from headings within the document, you don't need the information in this tip. Instead, you should refer to the TOC tips provided in other issues of WordTips. If you are creating a specialized TOC, however, then you will need the information in this tip. Examples of a specialized TOC would be a table of figures, illustrations, or tables. To create these types of TOCs, you must follow these two basic steps:

  1. Specify what you want in the TOC.
  2. Generate the TOC.

The first step is done by the following these steps; the second is covered in the next tip.

  1. Position the insertion point immediately after the text you want included in the TOC.
  2. Press Ctrl+F9 to insert a set of field braces. Make sure the insertion point stays between the braces.
  3. Type tc, followed by the TOC entry within quotes. Thus, if you want the entry to be "North American Mammals", enter tc "North American Mammals" between the field braces.
  4. Repeat steps 1 through 3 for each TOC entry you want to define.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1399) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Specifying a Table of Contents Entry.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Using Chapter Numbers with Page Numbers

Do you need to add page numbers that include, as well, a chapter number? It's relatively easy to do, as described in this ...

Discover More

Referencing External Cell Colors

If you want to reference cell colors external to your current workbook, there is no way to do it using Excel functions. You ...

Discover More

Using Check Boxes

Check boxes, just like those used in Windows dialog boxes, can be a great addition to a worksheet. Here's how to add them and ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (menu)

Updating an Entire TOC from a Macro

The TOC (Table of Contents) is generated by a field. This field may be updated in a macro using a single command line.

Discover More

Creating a Simple TOC

Sometimes a table of contents created by Word can have a few too many bells and whistles. Here's how to get rid of the ...

Discover More

Creating a TOC that Includes Specific Styles

Want to create a special TOC that contains different elements of your document? It's easy to do if you consistently use ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 1?

2016-09-03 08:43:43

Ken Endacott

The method that I suggest is to place a bookmark just preceding the TOC, then insert a small image in the margin to the left of each heading and apply a hyperlink to the image. Clicking on the image will then cause the selection to jump back to the bookmark at the TOC.

The image can be a picture or shape but it must have "Through" wrapping style. It can then be dragged into position in the margin to the left of the heading. Right click on the image and select Hyperlink then select "Place in This Document" and select the bookmark.

If you are really cunning you could use a borderless empty shape such as a small circle that would not show up when you print.

When setting up or adjusting the shape's position it is annoying that clicking the shape causes a jump to the TOC. Set Options > Advanced and tick "Use CTRL + Click to follow hyperlink" to avoid this. Don't forget to change back when you have finished.

Of course a suitable macro could do all of this for you with one click.


2016-09-02 16:38:13

Len

Hi Ken. Thanks for this but code like this makes my you-know-what pucker. Could it be possible to create a button or talisman of sorts which I could place beside each heading to take me to the ToC. I don't care about going to the specific entry I clicked.

Let me know.

Len
BTW, impressive coding. I wish I could do that.


2016-08-13 07:03:03

Ken Endacott

Len
The first macro links headings back to the appropriate line in the TOC. If you change headings or re-create the TOC then you should remove the reverse links with the second macro and then re-create them.

Sub HyperlinkHeadings()
Dim hyp As Hyperlink
Dim toc As TableOfContents
Dim bkmk As String
Dim bkmkR As String
Dim sCode As String
If ActiveDocument.TablesOfContents.Count = 0 Then
MsgBox "There are no Tables of Contents in document"
Exit Sub
End If
Options.CtrlClickHyperlinkToOpen = True
Set toc = ActiveDocument.TablesOfContents(1)
For Each hyp In toc.Range.Hyperlinks
bkmk = hyp.SubAddress
bkmkR = bkmk & "R"
hyp.Range.Select
If Selection.Bookmarks.Count = 0 Then
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:=bkmkR
Else
bkmkR = Selection.Bookmarks(1).Name
End If
If ActiveDocument.Bookmarks.Exists(bkmk) Then
ActiveDocument.Bookmarks(bkmk).Range.Select
If Selection.Hyperlinks.Count = 0 Then
With ActiveDocument.Hyperlinks.Add(Anchor:=Selection.Range, _
Address:="", SubAddress:=bkmkR, TextToDisplay:=Selection.Text)
.Range.Select
Selection.ClearCharacterAllFormatting
End With
Else
Selection.Range.Hyperlinks(1).Range.Select
Selection.Fields.Unlink
sCode = Selection.Text
With ActiveDocument.Hyperlinks.Add(Anchor:=Selection.Range, _
Address:="", SubAddress:=bkmkR, TextToDisplay:=sCode)
.Range.Select
Selection.ClearCharacterAllFormatting
End With
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:=bkmk
End If
End If
Next hyp
Options.CtrlClickHyperlinkToOpen = False
End Sub

Sub RemoveReverseLinks()
Dim hyp As Hyperlink
Dim toc As TableOfContents
Dim bkmk As String
If ActiveDocument.TablesOfContents.Count = 0 Then
MsgBox "There are no Tables of Contents in document"
Exit Sub
End If
Set toc = ActiveDocument.TablesOfContents(1)
For Each hyp In toc.Range.Hyperlinks
bkmk = hyp.SubAddress
If ActiveDocument.Bookmarks.Exists(bkmk) Then
ActiveDocument.Bookmarks(bkmk).Range.Select
Selection.MoveEnd unit:=wdCharacter, Count:=-1
If Selection.Hyperlinks.Count > 0 Then
Selection.Range.Hyperlinks(1).Range.Select
Selection.Fields.Unlink
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:=bkmk
If ActiveDocument.Bookmarks.Exists(bkmk & "R") Then
ActiveDocument.Bookmarks(bkmk & "R").Delete
End If
End If
End If
Next hyp
End Sub


2016-08-12 14:59:15

Len Babin

A while back, I asked how I could click on a ToC item, go to the heading in the text, then click back to the ToC. I got some good suggestions but no solutions.

I just received an HTML email with a ToC in it. Beside each heading in the text is a link which says "Return to Headlines" (the ToC) That makes me think that I could do this in a Word document. How can I create a link at each heading that will take me back to the ToC, ideally to the header link but at least to the top of the ToC?

Thanks - Len


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.