3 Ways to Quickly Insert a Table of Contents into Your Word Document

In this post, we would show you 3 ways of how to quickly insert a table of contents into your Word document.

While reading a document in Word, you can use either table of contents or navigation pane to help yourself look through contents quickly. Yet when it comes to printing, the navigation pane cannot be printed along with document. But, the former does. Therefore, it’s necessary to insert a table of contents into a Word document, especially a long one. Following are 3 effectual methods.

Method 1: Insert a Table of Contents Manually

  1. Firstly, put cursor at the place where you want the table of contents goes. Click “References” tab then the “Table of Contents” command.
  2. Next select “Insert Table of Contents”.Click "References"->Click "Table of Contents"->Click "Insert Table of Contents"
  3. In the dialog box open, set up the configurations as you need, such as the “Show levels”.
  4. Click “OK”.Set up configurations->Click "OK"

Usually, we place table of contents at the first page of document. If you have inserted page number before, you will find the main document now starts at page 2. Then here is the situation. Some people will want the main document page starts at page 1 as usual while the table of contents shall be excluded from page numbering. To do this, you will need extra operations. Read this article for detailed instructions: How to Start Page Numbering from a Specific Page in Your Word

And remember to update your table of contents after all the adjustments.

Method 2: Run Word Macro

As you see, the manual way to insert a table of contents is a bit tiresome, with such issues as resetting page numbers. For this reason, we recommend you using the macro way to fulfill this task. With a macro, you can have the entire process automatically performed in seconds.

  1. First off, press “Ctrl+ Home” to go to the start of document.
  2. Then press “Alt+ F11” to trigger VBA editor.
  3. Next click on “Normal” and then “Insert”.
  4. Choose “Module” and double click on it to open the editing area.Click "Normal"->Click "Insert"->Click "Module"
  5. Then paste the following codes there:
Sub InsertTOC()
  Selection.InsertBreak Type:=wdSectionBreakNextPage
  Selection.HomeKey Unit:=wdStory
  With ActiveDocument
    .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
      True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
      LowerHeadingLevel:=9, IncludePageNumbers:=True, AddedStyles:="", _
      UseHyperlinks:=True, HidePageNumbersInWeb:=True, UseOutlineLevels:= _True
    .TablesOfContents(1).TabLeader = wdTabLeaderDots
    .TablesOfContents.Format = wdIndexIndent
  End With
  ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
  With ActiveDocument.Sections(2)
    .Footers(wdHeaderFooterPrimary).LinkToPrevious = False
    .Footers(wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = True
    .Footers(wdHeaderFooterPrimary).PageNumbers.StartingNumber = 1
  End With
  ActiveDocument.TablesOfContents(1).Update
End Sub
  1. Last but not the least, click “Run”.Paste codes->Click "Run"

After running macro, the newly inserted table of contents will be put at the first page and the page numbering starts at the second one. Also, the table of contents is already updated.Effect of running a macro

Method 3: Insert Tables of Contents into Multiple Documents

In case you like the easiness of batch processing, you utilize the bellowing macro:

Sub InsertTOCForMultiDoc()
  Dim objDoc As Document
  Dim strFile As String, strFolder As String
 
  '  Initialization
  strFolder = "C:\Users\Public\Documents\New folder\Test1\"
  strFile = Dir(strFolder & "*.docx", vbNormal)
 
  '  Precess each document in the folder.
  While strFile <> ""
    Set objDoc = Documents.Open(FileName:=strFolder & strFile)
 
    Selection.InsertBreak Type:=wdSectionBreakNextPage
    Selection.HomeKey Unit:=wdStory
    With ActiveDocument
      .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
        True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
        LowerHeadingLevel:=9, IncludePageNumbers:=True, AddedStyles:="", _
        UseHyperlinks:=True, HidePageNumbersInWeb:=True, UseOutlineLevels:= _
        True.TablesOfContents(1).TabLeader = wdTabLeaderDots
      .TablesOfContents.Format = wdIndexIndent
    End With
    ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
    With ActiveDocument.Sections(2)
      .Footers(wdHeaderFooterPrimary).LinkToPrevious = False
      .Footers(wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = True
      .Footers(wdHeaderFooterPrimary).PageNumbers.StartingNumber = 1
    End With
    ActiveDocument.TablesOfContents(1).Update
 
    objDoc.Save
    objDoc.Close
    strFile = Dir()
  Wend
End Sub

Just follow the same steps in method 2 to install and run the macro.

Notes

  1. You must arrange all documents under the same directory first.
  2. Never forget to replace the “C:\Users\Public\Documents\New folder\Test1\” with your actual folder path. Don’t forget the last “\”.

Repairing Tool for Word

Since Word will crash all of a sudden, it’s a must to prepare a tool to repair Word and Word documents. A timely recovery can get as most data as possible. Therefore, it’s advisable to obtain a proficient product beforehand.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including Excel fix and pdf repair software products. For more information visit www.datanumen.com

One response to “3 Ways to Quickly Insert a Table of Contents into Your Word Document”

Leave a Reply

Your email address will not be published. Required fields are marked *