AFAIK, pandoc can only insert a placeholder for a ToC into a docx document, but not create a full ToC itself.
Updating from the command line is possible, too (at least when using LibreOffice [LO]).
```
sub UpdateAllIndexes(sDocUrl as string)
dim oDocument as object
dim dispatcher as object
dim propExp(0) as new com.sun.star.beans.PropertyValue
dim sNewUrl as string
Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "Hidden"
FileProperties(0).Value = True
if fileExists(sDocUrl) then
oDocument = starDesktop.loadComponentFromUrl(convertToUrl(sDocUrl), "_blank", 0, FileProperties())
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(oDocument.CurrentController.Frame, ".uno:UpdateAllIndexes", "", 0, Array())
GlobalScope.BasicLibraries.LoadLibrary("Tools")
propExp(0).Name = "FilterName"
propExp(0).Value = "MS Word 2007 XML"
sNewUrl = GetFileNameWithoutExtension(sDocUrl) & "_updated.docx"
oDocument.storeToURL(convertToUrl(sNewUrl), propExp())
end if
end sub
```
This macro can then be run from the command line (the following works on macOS):
```
```
… creating a new file `/full/path/to/file_updated.docx`.
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/I80KhRRTIZtqDS6YtSd0sn82PQLGziJEjj2sjDDddOo_KTaCx9bTm1rY-DJsxjJSc2ymofEp2QHoQ6hyzN1y46N0No6jor8j_oMBYWEdDjM%3D%40protonmail.com.