There is often a problem that indexes, such as the table of contents (which is a type of index), aren't updated after changes have occured. Documents can be sent with incorrect links.
This macro updates automatically the links in an index. It can be useful to link the macro to the command Save document (▸ ▸ ▸ ), so that the links will be updated when the document is saved.
In the example of Table of Contents, imagine that you have created a document with various headers (which are assigned by right-click and▸ , etc). And then now you insert a TOC by ▸ ▸ . Then if you add more headers, you can update the TOC by simply running this macro.
Option Explicit Sub UpdateIndexes() '''Update indexes, such as for the table of contents''' If ThisComponent.supportsService("com.sun.star.text.GenericTextDocument") Then For i = 0 To ThisComponent.getDocumentIndexes().count - 1 ThisComponent.getDocumentIndexes().getByIndex(i).update() Next i End If End Sub ' UpdateIndexes