使用 Python.Net 自动化 Microsoft word

Automating Microsoft word with Python.Net

如何使用与 python.net 的 office 互操作来自动化 Microsoft office? 我试过以下但给出错误:

import clr
clr.AddReference("System")
clr.AddReference("Microsoft.Office.Interop")

from Microsoft.Office.Interop import Word

wordApp = Word.Application()
wordApp.Visible = True
doc1 = wordApp.Documents.Add()

AttributeError: '__ComObject' object has no attribute 'Add'

我写了一个简单的包装器,使 COM 与 pythonnet 互操作。完整的细节在这里:

https://github.com/pythonnet/pythonnet/issues/260