Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Apr 09, 2020 9:16 am

Hello

I have created a TOC manually in my document (Office 365) so I can apply custom styling etc and are trying to update it once I have finished manipulating my document.
In an ideal world I don't wan to manually created the TOC as I'd like to keep the current styling and just update the table. I've tried two different methods of updating the TOC (all before saving the document)
Code: Select all
document.UpdateTableOfContents()

This does nothing and leaves the table as is.
The next option was to find the table of contents within the document then call the following code
Code: Select all
document.UpdateTableOfContents(toc)

This actually removes the TOC altogether leaving nothing.

Can you help with with the correct code to update an existing table of contents.
For reference, to do this in word you would Right Click the TOC, select Update Field then choose Update Entire Table.

Thanks

fredriko
 
Posts: 1
Joined: Wed Apr 01, 2020 1:58 pm

Thu Apr 09, 2020 10:02 am

Hello,

Thanks for your inquiry.
I simulated a file and tested with the latest Spire.Doc Pack(hot fix) Version:8.3.15, but didn't reproduce your issue. The TOC was successfully updated using the code "document.UpdateTableOfContents()". If you are using an old version, please try again with the latest version.
If the issue still happens, to help us investigate your issue more accurately, please provide your full code as well as your input file. You could send them to us([email protected]) via email.

Sincerely,
Rachel
E-iceblue support team.
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc