Free Support Forum - aspose.com

Update of Word Table of Contents (Java 1.4 version)

I'm using Aspose.Words (Java 1.4) version to insert a number of tables into an existing Word document (that contains a Table of Contents).

After the insert of the tables, the TOC is no longer correct (page numbers have changed).

Is it possible to get the TOC to update ?

No, you can only update TOC by opening file in MS Word and pressing F9.

Is it technically possible for Aspose.Words to update the existing TOC ?

Currently it is not possible. It will be implemented in one of the future versions together with other major updates.

If you do not want the users to keep pressing F9 you could write a word macro as follows:

Sub AutoOpen()
'
' autoopen Macro
' Macro created 03/03/2006 by William.W that refreshes the
' document's table of contents
'
Dim aTOC As TableOfContents
For Each aTOC In ActiveDocument.TablesOfContents
aTOC.Update
Next aTOC

End Sub

The downside is that your users will either have to enable macros for their word installations or have a warning dialog pop up everytime the document is opened.