I'm having trouble with a COM object for which none of its methods are
available at runtime.  The COM class is defined in a tlb file.  I used
"makepy -i", added the gencache lines to the program, and can see the
methods in the generated file.  However, when I try to call any method,
it blows up with a DISPATCH_METHOD flag error.

The equivalent code works just fine in Perl.

Anyone have any idea why a COM object defined in a tlb file would be so
problematic in Python?


=== program ===
import win32com.client

from win32com.client import gencache
gencache.EnsureModule('{A5B37030-06D9-11D2-A58A-006097B17A75}', 0, 4, 0)

gui = win32com.client.Dispatch("ReqPro40.GUIApp")
print gui
print
print dir(gui)

print
print 'showword =', gui.ShowWord()



== output ==
<COMObject ReqPro40.GUIApp>

['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum',
'_Release_', '__AttrToID__', '__LazyMap__', '__call__', '__cmp__',
'__doc__', '__getattr__', '__getitem__', '__init__', '__int__',
'__len__', '__module__', '__nonzero__', '__repr__', '__setattr__',
'__setitem__', '__str__', '_builtMethods_', '_enum_',
'_find_dispatch_type_', '_get_good_object_', '_get_good_single_object_',
'_lazydata_', '_make_method_', '_mapCachedItems_', '_oleobj_',
'_olerepr_', '_print_details_', '_proc_', '_unicode_to_string_',
'_username_', '_wrap_dispatch_']

showword =
Traceback (most recent call last):
  File "D:\mydata\dev\reqpro\renumber\c.py", line 13, in <module>
    print 'showword =', gui.ShowWord()
  File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line
491, in __getattr__
    raise pythoncom.com_error, details
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
'Smalltalk', 'Incorrect dispatch invocation flags: DISPATCH_METHOD flag
not set for method ShowWord.', None, 0, 0), None)


=== snippets of gen file ====

CLSID = IID('{A5B37030-06D9-11D2-A58A-006097B17A75}')
...
from win32com.client import DispatchBaseClass
class IReqProGUIApp(DispatchBaseClass):
        """RequisitePro GUI Application Dispatch Interface"""
        CLSID = IID('{52795522-11D4-11D2-A59B-006097B17A75}')
        coclass_clsid = None

        ...

        def ShowWord(self):
                """Brint the Word Workplace to the front."""
                return self._oleobj_.InvokeTypes(209, LCID, 1, (11, 0),
(),)



*****

The information transmitted is intended only for the person or entity to which 
it is addressed and may contain confidential, proprietary, and/or privileged 
material. Any review, retransmission, dissemination or other use of, or taking 
of any action in reliance upon this information by persons or entities other 
than the intended recipient is prohibited. If you received this in error, 
please contact the sender and delete the material from all computers. GA621


_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to