python-更新word目录
import win32com.client
word = win32com.client.DispatchEx("Word.Application")
try:
doc = word.Documents.Open(docx_file)
for contentCount in range(1, doc.TablesOfContents.Count+1):
doc.TablesOfContents(contentCount).Update()
for FigureCount in range(1, doc.TablesOfFigures.Count+1):
doc.TablesOfFigures(FigureCount).Update()
doc.Close(SaveChanges=True)
finally:
word.Quit()