主页 >> 程序猿的东西 >> LibreOffice 更新目录页码的宏

LibreOffice 更新目录页码的宏

Sub UpdateTableOfContents(path As String)
     '''Update indexes, such as for the table of contents''' 
     Dim doc As Object
     Dim args()

     doc = StarDesktop.loadComponentFromUrl(convertToUrl(path), "_default", 0, args())
     'doc=ThisComponent

     Dim i As Integer

     With doc ' Only process Writer documents
         If .supportsService("com.sun.star.text.GenericTextDocument") Then
             For i = 0 To .getDocumentIndexes().count - 1
                 .getDocumentIndexes().getByIndex(i).update()
             Next i
         End If
     End With ' ThisComponent

     doc.store()
     doc.close(True)
End Sub
滚动至顶部