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

Mark Hammond skippy.hammond at gmail.com
Sun Dec 16 06:46:13 CET 2012


On 15/12/2012 12:56 AM, Dave Calkins wrote:
>
> 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.

That's very strange.  pywin32 *will* be passing a second param - a byref 
bstr.  byref params do work in general, so you might need to contact the 
vendor of the object for help.

Cheers,

Mark

>
> =====
>  >>> 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