Search code examples
c#fieldauto-updatetableofcontents

Update existing table of contents - Apache-POI | Word SDK | Other api


Is it possible to update an existing toc with apache poi/Word SDK/ other api's? Or is there a workaround for it? E.g. removing the old toc then grabbing all headlines and adding them to the new toc or inserting them into the right place without deleting them in the beginning.

Edit: I'm working with .doc but I could change it to .docx so it doesn't really matter.


Solution

  • I did this now with the Office SDK (C#) and an AutoIT Script. The C# code sets the fields update flag in the settings (class). The AutoIT script opens word, clicks through the dialogues, saves and closes the doc again. It s dirty but working.