xxxxxxxxxx
import win32com.client as win32
# Specify the path of the Word document
doc_path = "path_to_document.docx"
# Create a Word application object
word_app = win32.gencache.EnsureDispatch('Word.Application')
# Open the Word document
doc = word_app.Documents.Open(doc_path)
# Update all fields in the document
word_app.ActiveDocument.Fields.Update()
# Save and close the document
doc.Save()
doc.Close()
# Quit Word application
word_app.Quit()