[python-win32] Access COM object thru other than default interface

paul at alanweberassociates.com paul at alanweberassociates.com
Tue Aug 10 21:01:44 CEST 2004


I am working with a COM object that has the following custom COM class, with two coclass_interfaces (names have been changed to protect the proprietary):

class MainObject(CoClassBaseClass): # A CoClass
	# Brand X MainObject Class
	CLSID = IID('{DEADBEEF-FFFF-1111-2222-000000000000}')
	coclass_sources = [
	]
	coclass_interfaces = [
		IAAAObject,
		IBBBObject,
	]
	default_interface = IAAAObject

I am able to create a MainObject using
    myobj = win32com.client.Dispatch("BrandX.MainObject")
and this gives me a myobj that repr's as:
<win32com.gen_py.BrandX Type Library.IMainObject instance at 0x23592352>

and on myobj I can do invoke all of the IAAAObject methods.

Now I need to do some IBBBObject-type work.  How do I get to the IBBBObject methods?  I've tried just invoking them, but I get the following error:

Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__
    raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr)
AttributeError: '<win32com.gen_py.BrandX Type Library.IMainObject instance at 0x23592352>' object has no attribute 'IBBBObjectMethod'

(I've looked thru Python Programming on Win32, but I've not seen anything that looks relevant.)

Thanks for the help, even if you can just RTFM me to an existing doc resource.

-- Paul

 


More information about the Python-win32 mailing list