Thread: [Solved] Update TOC
View Single Post
 
Old 07-31-2012, 05:44 AM
Venky62 Venky62 is offline Windows 7 64bit Office 2010 32bit
Advanced Beginner
 
Join Date: Jul 2012
Posts: 58
Venky62 is on a distinguished road
Post

You will have to create a Autoclose macro for that.
1. Press Alt+F11. This will open the Macro code window.
2. On the left hand side, there is a window called Project. Under the Window, go to the Project which has the name of your document. If you double-click on that, it expands and will show "This Document" below. Double-click on "This Window".
2. In the blank window on the right hand side, type the text given below between the dotted lines:
-------
Sub AutoClose()

ActiveDocument.TablesOfContents(1).Update

End Sub
----------
3. Close the window and save the file. Test and see. Make a change in the headings, and close the document without updating TOC. When you reopen it, you should find the TOC updated.

This code assumes that you have only one TOC in your document. If you have more than one, then you have to change the number in the brackets of TablesOfContents() accordingly. If it is the second TOC, then it will be TablesOfContents(2) and so on.
Reply With Quote