Python word自动化脚本仅选中部分复选框

Python word自动化脚本仅选中部分复选框,python,ms-word,automation,ironpython,Python,Ms Word,Automation,Ironpython,我编写了一个IronPython脚本来检查Word文档中的所有复选框。但是,它只检查其中的一些 input.docx是一个Word文档,其中包含许多复选框,所有复选框均未选中。 如果我运行脚本,output.docx包含与input.docx相同的内容,只是选中了一些复选框。我的目的是检查所有的 我的剧本有什么问题 # Add the reference for Word import clr clr.AddReference("Microsoft.Office.Interop.Word") i

我编写了一个IronPython脚本来检查Word文档中的所有复选框。但是,它只检查其中的一些

input.docx
是一个Word文档,其中包含许多复选框,所有复选框均未选中。 如果我运行脚本,
output.docx
包含与
input.docx
相同的内容,只是选中了一些复选框。我的目的是检查所有的

我的剧本有什么问题

# Add the reference for Word
import clr
clr.AddReference("Microsoft.Office.Interop.Word")
import Microsoft.Office.Interop.Word as Word

# Start Word
word_application = Word.ApplicationClass()
word_application.visible = False

# Open the input file
document = word_application.Documents.Open(r"c:\tst\input.docx")

# Check all the checkboxes
for ctrl in document.ContentControls:
    ctrl.Checked = True

# Save and close the output file
document.SaveAs(r"c:\tst\output.docx")
document.Close()

# Quit Word
word_application.Quit()