I have been looking for a way to impliment a table of contents with page numbers. Is this possible with the most recent version of Aspose.Word? I have read many forum posts about this, but none of them seem to help.
The function InsertTableOfContents() doesn’t display anything. I beleive this is because I have not marked TOC anchors correctly. Furthermore, after getting the latest version (2.5.4) every place where my Header 1 sections are, the text {TC “I. Introduction” \f C \l “1”} appears.
I have also tried using a Document_Open() macro to update an existing TOC in the template. This method, while properly displaying the contents of the export, still does not update the table of contents. The macro doesn’t run when the document opens and I get an error when I try to run the macro. This is the error message: “The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros.” Here is the macro that I am trying to use:
Private Sub Document_Open()
'This macro will run when the word document first opens
'Update the table of contents
UpdateTOC
End Sub
Sub UpdateTOC()
'Application.Assistant.DoAlert “UpdateTOC”, “UpdateTOC”, msoAlertButtonOK, msoAlertIconInfo, msoAlertDefaultFirst, msoAlertCancelFirst, False
With ActiveDocument.TablesOfContents(1)
.UpdatePageNumbers
.Update
ActiveDocument.Repaginate
.Update
.Range.ParagraphFormat.Reset
End With
End Sub