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

paul at alanweberassociates.com paul at alanweberassociates.com
Wed Aug 11 07:53:59 CEST 2004


Thanks, this is just what worked.  (Yes, Jens, I am using makepy'ed modules, but I can't just create an IBBBObject() - the only thing that works is to first create a Dispatch, and then use that to construct an IBBBObject.)

    myobj = win32com.client.Dispatch("BrandX.MainObject")
    objWith2ndInterface = BrandX.IBBBObject( myobj )
    objWith2ndInterface.IBBBObjectMethod()

-- Paul


-----Original Message-----
From: Jens B. Jorgensen [mailto:jens.jorgensen at tallan.com]
Sent: Tuesday, August 10, 2004 2:44 PM
To: paul at alanweberassociates.com
Cc: python-win32 at python.org
Subject: Re: [python-win32] Access COM object thru other than default
interface


It's been a while since I've done exactly this but I think what you want 
to do is create an IBBBObject passing the object reference to it as a 
parameter. I think you'll need to be using the makepy'd module for this 
but I notice you are creating the object through Dispatch rather than 
the module. Are you not including a makepy'd module?

paul at alanweberassociates.com wrote:

>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
>
> 
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32 at python.org
>http://mail.python.org/mailman/listinfo/python-win32
>  
>


-- 
Jens B. Jorgensen
jens.jorgensen at tallan.com

"With a focused commitment to our clients and our people, we deliver value through customized technology solutions"  



More information about the Python-win32 mailing list