设置参数化 COM 属性
Set parameterized COM property
获取参数化 属性(Ms Word 的 Options.DefaultFilePath
)工作正常:
In [117]: o
Out[117]: <win32com.gen_py.Microsoft Word 12.0 Object Library.Options instance at 0x43743792>
In [121]: o.DefaultFilePath(win32com.client.constants.wdDocumentsPath)
Out[121]: u'c:\documents and settings\user\\u043c\u043e\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b\\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u043f\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0438'
但未设置:
In [122]: o.DefaultFilePath(win32com.client.constants.wdDocumentsPath)=".."
File "<ipython-input-122-f2ed5d26c67c>", line 1
o.DefaultFilePath(win32com.client.constants.wdDocumentsPath)=".."
SyntaxError: can't assign to function call
还尝试了 C# Late Binding for Parameterized Property 的建议方法:
In [123]: o.set_DefaultFilePath(win32com.client.constants.wdDocumentsPath,"..")
<...>
AttributeError: '<win32com.gen_py.Microsoft Word 12.0 Object Library.Options instance at 0x43743792>' object has no attribute 'set_DefaultFilePath'
In [160]: dir(o)
Out[160]:
['CLSID',
'DefaultFilePath',
'SetDefaultFilePath',
'SetWPHelpOptions',
<...>
这表明:
o.SetDefaultFilePath(win32com.client.constants.wdDocumentsPath,u"..")
获取参数化 属性(Ms Word 的 Options.DefaultFilePath
)工作正常:
In [117]: o
Out[117]: <win32com.gen_py.Microsoft Word 12.0 Object Library.Options instance at 0x43743792>
In [121]: o.DefaultFilePath(win32com.client.constants.wdDocumentsPath)
Out[121]: u'c:\documents and settings\user\\u043c\u043e\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b\\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u043f\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0438'
但未设置:
In [122]: o.DefaultFilePath(win32com.client.constants.wdDocumentsPath)=".."
File "<ipython-input-122-f2ed5d26c67c>", line 1
o.DefaultFilePath(win32com.client.constants.wdDocumentsPath)=".."
SyntaxError: can't assign to function call
还尝试了 C# Late Binding for Parameterized Property 的建议方法:
In [123]: o.set_DefaultFilePath(win32com.client.constants.wdDocumentsPath,"..")
<...>
AttributeError: '<win32com.gen_py.Microsoft Word 12.0 Object Library.Options instance at 0x43743792>' object has no attribute 'set_DefaultFilePath'
In [160]: dir(o)
Out[160]:
['CLSID',
'DefaultFilePath',
'SetDefaultFilePath',
'SetWPHelpOptions',
<...>
这表明:
o.SetDefaultFilePath(win32com.client.constants.wdDocumentsPath,u"..")