Updating an Existing Table of Contents - Apache-POI | Word SDK | Other api

Is it possible to upgrade an existing toc using apache poi / Word SDK / other api? Or is there a workaround? For instance. removing the old toc, then grab all the headers and add them to the new toc or paste them in the right place without deleting them at the beginning.

Edit: I work with .doc, but I can change it to .docx, so that doesn't really matter.

+4
source share
2 answers

I did it now with the Office SDK (C #) and AutoIT Script. C # code sets the flag for updating fields in settings ( class ). AutoIT script opens a word, clicks on dialogs, saves and closes the document again. It is dirty but working.

+2
source

If you are using XWPFDocument, just do document.enforceUpdateFields (). However, he still offers the user that he / she wants to update the files that are referenced each time .docx is opened.

0
source

All Articles