我编写了一个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()
目前没有回答
相关问题 更多 >
编程相关推荐