Macro for automatic updating file paths

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


Description

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 RefreshDirectories
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
End If
End Sub ' RefreshDirectories