This project has moved and is read-only. For the latest updates, please go here.

Update table of contents to match data that was filled

Jun 6, 2016 at 2:25 PM
Is there a way to update table of contents? I'm just reading word template and replacing tags with data but problem is the ToC stays the same regardless what I do. Is there a way to update ToC with DocX?
Jun 6, 2016 at 5:27 PM
There was a patch you can take a look at: 16114 by drverboten Mar 28, 2014

Files for creating an Index in the document, an empty TOC (Table of Contents) has to be created in the template, this code will add the setting in the XML to let know Word that it has to update the TOC the first time the document it is opened, the contents of the table will be automatically populated.

Declined Apr 14, 2015: New patch was proposed with better options

There is code with it thou so maybe you can reuse parts of it to get it and modify it and then apply to sources on github.
Jun 6, 2016 at 8:01 PM
Edited Jun 6, 2016 at 8:04 PM
I'm not so sure if my programming skills are on the level to modify the code. What do you mean by "Files for creating index in document" I didn't quite understand this part. Is there maybe some example for it?

I saw there is code for adding New table of contents programatically, but I don't need that, I need to just fill data into the document and refresh ToC.
Jun 6, 2016 at 8:23 PM
The patch includes multiple options. One of which is inserting TOC. Which was added in other patch by using different way. You just need to find a code responsible for forcing the rebuild of TOC. It has to be there. Then you would need to take newest GITHUB docx source code and add it into the code, compile and try to use :-)
Jun 6, 2016 at 8:44 PM
Alright ty, I will try to figure something out.