Table of contents not updated properly

I am using Aspose.Words for .NET 9.5.0. I created a small Word 2003 DOC file. Afterwards when I create an Aspose.Words Document object for it, then call the Document UpdateFields and UpdatePageLayout methods and save it. After I open the file in Word 2007 I see the message
No table of contents entries found.
in the table of contents. If I select the entire text in Word and press F9, the table of contents gets updated to
Section 1. Deposits
1.01 Separate Investment Account Allocations… 3
which is what I’d expect. F9 does this also if open the file in Word without running it through Aspose.Words. Why am I getting this error message? Is it a bug/limitation in Aspose.Words, or do I need to use Aspose.Words in a different way to get what I want?

Hi Mark,
Thanks for your inquiry.
I managed to reproduce the problem on my side. The issue has been linked and we willl look into fixing it sometime in the future.
There are two issues with the TOC in your document .Firstly it is missing the “\u” switch, this updates fine in MS Word but does not update in Aspose.Words. If you include this switch the TOC will be populated.
The second issue arises because the bookmark switch is not supported yet. Even content outside of the bookmark will be included in the TOC for now.

Thank you for your reply. I’ll see if it will help us to use the \u switch and avoid the \b switch, as was suggested.
You mentioned that the bookmark switch is not yet supported. However in for version 9.0.0 it is stated: “If you want a table of contents in such a document, you want it to be filled with the correct entries and page numbers. Aspose.Words now supports the Microsoft Word TOC field completely with all of its formatting switches and builds a table of contents that you will not be able to distinguish from the one built by Microsoft Word itself.” I thought this meant the bookmark switch was supported.
Thanks for your quick response.

A co-worker of mine suggested that forcing the use of the “\u” switch is an unnecessary limitation and should be documented. She also said that by default Word uses the “\o” switch, not the “\u” switch.


Thank you for additional information. Adam is right, TOC of bookmarked content (\b switch) is not yet supported. We already linked your request to the appropriate issue. You will be notified as soon as it is resolved.
Also, regarding default settings of TOC using by MS Word. Here is code of TOC inserted by MS Word by default:
{ TOC \o “1-3” \h \z \u }
Best regards,

Hi Mark,
Regarding the first issue with the “\u” switch, I have been working on documentation relating to TOCs and have taken a closer look at your issue in the process. I found that the behaviour seen when updating the TOC in your document using Aspose.Words is actually caused by a completely different issue.
To clarify, Aspose.Words will update a TOC with just the heading \o switch and without the “\u” switch properly. After some further investigation I found the behaviour of these switches is actually different and that the Office documentation is a bit misleading.
In MS Word the “\o” switch actually appears to behave in a way which includes any style which has an outline level, not just in-built styles as is commonly assumed. So in other words with that switch MS Word actually builds the TOC from the outline levels of styles, not the actual in built heading styles themselves. You can test this by creating a new style and giving it an outline level under Paragraph options, e.g Level 1. Any paragraphs styled with this will be included in the TOC using the “\o” switch.
The heading styles and outlines levels are still strongly related as the Heading 1 style will always have a Level 1 outline, Heading 2 will have Level 2 etc. These levels cannot be changed for built-in styles.
The “\o” switch is better described as specifying the range of the outline levels to include in the TOC, similar to the “\l” switch when using TC fields. Furthermore the only difference between using the default heading switch “\o” to include all levels and the “\u” is that the first switch will only include all styles with an outline level, whereas the second switch will include all paragraphs with outline levels. i.e. a paragraph styled with a style that has no outline level but the paragraph itself has an outline level defined.
In your attached document the content to be included in the TOC is styled using “Heading 2_0”. This is not an in-built heading but however does have the same level outline as the Heading 2 style which means it is picked up by MS Word and included. Aspose.Words currently does not pick this up as it’s using the actual in-built heading styles. I have changed the defect description to reflect these findings. We will inform you when this issue and the one regarding bookmarks are resolved

The issues you have found earlier (filed as 21573) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-3511) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.