Written by Allen Wyatt (last updated November 16, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and 2021
If you have a document that contains a table of contents (TOC), and you update the fields in the entire document, Word asks if you want to update the entire table, the chapter entries, or just the page numbers associated with the existing chapter entries in the Table of Contents. This occurs because TOCs are implemented through the use of a field, and when you update all fields you are telling Word you also want to update the field underlying the TOC.
You can update a TOC using a macro by utilizing the TablesOfContents collection. Each item in the collection represents a single TOC in the document. (In most documents the collection will consist of only a single item.) To update the entire TOC, you use this format of the command:
ActiveDocument.TablesOfContents(1).Update
The Update method is what does the work; it updates the TOC. If you want to update only the page numbers in the TOC, you use an entirely different method:
ActiveDocument.TablesOfContents(1).UpdatePageNumbers
Whenever you use commands like these in a macro, it is a good idea to make sure that there is actually a TOC in the document before you try to do any updating. The easiest way to do this is to just check the Count property for the collection, as shown here:
If ActiveDocument.TablesOfContents.Count = 1 Then _ ActiveDocument.TablesOfContents(1).Update
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (8621) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and 2021. You can find a version of this tip for the older menu interface of Word here: Updating an Entire TOC from a Macro.
Do More in Less Time! An easy-to-understand guide to the more advanced features available in the Microsoft 365 version of Word. Enhance the quality of your documents and boost productivity in any field with this in-depth resource. Complete your Word-related tasks more efficiently as you unlock lesser-known tools and learn to quickly access the features you need. Check out Microsoft 365 Word For Professionals For Dummies today!
If your document is any length at all, adding a table of contents is a nice touch. This tip demonstrates how easy it is ...
Discover MoreWant to create a special TOC that contains different elements of your document? It's easy to do if you consistently use ...
Discover MoreLinda's got a document that includes a table of contents that is based on headings in the document. When the headings ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2025-08-28 11:57:29
Barbie
This worked great, but would have been even more useful if it had addressed the possibility that you do, in fact, have more than one TOC. I tried adapting the code for determining if there is a TOC to update the second one if there are two, etc., but still only the first one was updated. Finally, I was able to find code on another website that indeed steps through and updates all TOCs in a document. This was acceptable, though I would have liked to be able to update just the TOC I have the cursor in... Unfortunately, VBA code is basically a foreign language to me, so I can only make minor adjustments and still have it work.
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments