Share via

Incomplete Table of Contents created by Word 2013

Anonymous
2017-03-11T14:37:08+00:00

Hello all,

I have just encountered a peculiar issue in Word 2013. I have been working on a large document that has a table of contents. The TOC was previously built by means of:

References -> Table of Contents -> Automatic Table of Contents

After updating the document I normally delete the entire TOC and use the above sequence to build it from scratch.

Today, after having deleted the TOC and repeating the sequence above, Word has only created a partial table. The second half of the table was not created. I tried hitting F9 and I tried Update Table -> Update entire table - both to no avail. Each time I try to create the table it is truncated.

I repeated the process with older versions of the same document (where the TOC was created with no problem). In some the table was built successfully. In some (the recent versions) it was not. The table has about 150 entries listing Heading 1, 2, and 3 titles.

My feeling is that the problem has to do with some Word-related registry entries being somehow corrupted, but I have no idea of how this can be verified or fixed.

Any help in solving this will be highly appreciated.

Thanks!

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Jay Freedman 207.6K Reputation points Volunteer Moderator
2017-03-11T18:17:08+00:00

The problem probably stems from your practice of deleting the previous TOC and inserting a new one. To see why, you need to understand how a TOC works "under the hood".

Each time you insert a TOC, Word creates a hidden bookmark for each heading (assuming you're using the default of building TOCs only from heading levels). You can see these bookmarks by opening the Insert > Bookmark dialog and checking the box for "Hidden bookmarks":

The TOC itself consists of references to those bookmarks.

When you delete a TOC, Word does not delete the hidden bookmarks that it used. In the screen shot above, the first five bookmarks are from a TOC that was built and then deleted, and the next five are from a second TOC that was inserted in its place.

Now consider what happens when 150 new bookmarks are created each time you revise your document. Although Microsoft documents the maximum number of bookmarks per document as slightly over 2 billion, I don't think you can reasonably have more than a few thousand without trouble.

To get you out of the current situation, run the following macro (see http://www.gmayor.com/installing_macro.htm if needed):

Sub DeleteHiddenTOCBookmarks()

    Dim bk As Bookmark

    Dim ix As Integer

    With ActiveDocument

        .Bookmarks.ShowHidden = True

        For ix = .Bookmarks.Count To 1 Step -1

            StatusBar = CStr(ix)

            Set bk = .Bookmarks(ix)

            If LCase(Left(bk.Name, 4)) = "_toc" Then

                bk.Delete

            End If

            DoEvents

        Next

    End With

End Sub

The macro will delete all the bookmarks left over from previous TOCs and the ones used by the current TOC. Then (and always in the future) click in the TOC and press F9, or click the tab at the top of the TOC and click Update Table; in the dialog that opens, choose to update the entire table, and click OK. Then Word will create new hidden bookmarks only for headings that don't already have them.

As an alternative, you can click the down arrow in the tag at the top of the TOC and click "Remove Table of Contents" at the bottom of the menu. That will remove the TOC and its hidden bookmarks (but not any orphans left behind by just deleting the TOC).

Was this answer helpful?

3 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2017-03-12T10:52:02+00:00

    Thanks Jay! You were right on target.

    The reason I have been deleting the table of contents instead of simply updating it, is because I noticed that Word sometimes changes the format of table entries after the update (size, font, etc.).

    In any case, I did exactly as you suggested. I used a copy of the original document to test the macro. Judging by the counter, there were over 16,000 hidden bookmarks!

    Interestingly though, the macro did not manage to delete them all. An error was displayed mid execution saying that Word has encountered a problem. However, since about 8,000 hidden bookmarks were deleted I finally managed to create the full table of contents again.

    By the way, the "Remove Table of Contents" option is grayed-out. Clicking inside the table or selecting some or all of the entries does not help.

    Thanks again!

    Was this answer helpful?

    0 comments No comments