[python-win32] Calling an OLE Automation (IDispatch) server which uses "out params"

Dave Calkins dave at kinematics.com
Fri Dec 14 14:56:08 CET 2012


On 12/13/2012 10:39 PM, Mark Hammond wrote:
> This is the form you should use, but the method name you are trying to 
> call is "GetSettingValue", not "GetSettingName", hence the 
> AttributeError.
>
> Mark

Ah, yes.  Good catch!  Unfortunately, correcting that typo didn't seem 
to fix it.  Here's what I get, when using the correct method name this time.

=====
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import win32com.client
 >>> x = win32com.client.Dispatch("MyApp.Application")
 >>> x.ShowMessage("Hello World")
 >>> x.SetSettingValue("testName","testValue")
 >>> testValue = x.GetSettingValue("testName")
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<COMObject MyApp.Application>", line 2, in GetSettingValue
pywintypes.com_error: (-2147352561, 'Parameter not optional.', None, None)
=====

It appears it does want that second parameter, but passing in a variable 
doesn't seem to work.

=====
 >>> testValue = ""
 >>> x.GetSettingValue("testName",testValue)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<COMObject MyApp.Application>", line 2, in GetSettingValue
pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 2)
=====




More information about the python-win32 mailing list