Macro for automatic updating file paths

From The Document Foundation Wiki
< Macros‎ | Writer
Jump to: navigation, search

Descriptions

There is often a problem that indexes, especially the table of contents aren't updated after changes happened. Documents can be sent with incorrect links.

This macro updates automatically file paths. If the macro gets linked to the command Save document (Extras ▸ Customize ▸ Events ▸ Save document), the file paths will be updated when the document is saved.

Code

Sub VerzeichnisseAktualisieren
dim i as long
   if thisComponent.supportsService ("com.sun.star.text.GenericTextDocument") then
   for i = 0 TO thisComponent.getDocumentIndexes().count - 1
     thisComponent.getDocumentIndexes().getByIndex(I).update()     
   NEXT I
else

end if
End Sub