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

Dave Calkins dave at kinematics.com
Tue Dec 18 15:10:06 CET 2012


On 12/17/2012 8:25 PM, Mark Hammond wrote:
> So after running makepy, a work-around is:
>
> >>> klass=win32com.client.gencache.GetClassForProgID("MyApp.Application")
> >>> x = klass()
> >>> x.GetSettingValue("foo")
> u'foo=testValue123'
> >>>
>

I tried the work-around.  I've run MakePy and then gave the above a 
try.  The first 2 methods worked, but I'm still getting an error on the 
last method.  I suspect I'm doing something wrong on my end, but am not 
sure what.

=====
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
 >>> klass=win32com.client.gencache.GetClassForProgID("MyApp.Application")
 >>> klass
<class win32com.gen_py.3D28B651-27E2-4057-A0AF-1D761C2D10CCx0x1x0.MyApp 
at 0x02374D18>
 >>> x = klass()
 >>> x.ShowMessage("Hello, world")
 >>> x.SetSettingValue("color","blue")
 >>> x.GetSettingValue("color")
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File 
"C:\Python27\lib\site-packages\win32com\gen_py\3D28B651-27E2-4057-A0AF-1D761C2D10CCx0x1x0.py"
, line 34, in GetSettingValue
     , settingValue)
pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 2)
=====




More information about the python-win32 mailing list