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.
|