Problem setting COM property using win32com
Green, Gregory P
gregory.p.green at boeing.com
Mon Apr 7 17:16:10 EDT 2003
I missed the last line in your example code:
so if I do (using the EnsureModule line):
prmidattrs = MyModule.ISmRecordList()
I get:
Traceback (most recent call last):
File "example.py", line 43, in ?
prmidattrs = MyModule.ISmRecordList()
File "C:\PYTHON22\lib\site-packages\win32com\client\__init__.py", line 310, in __init__
oobj = pythoncom.new(self.CLSID) pywintypes.com_error: (-2147221164, 'Class not registered', None, None)
pywintypes.com_error: (-2147221164, 'Class not registered', None, None)
If I use
prmidattrs = MyModule.SmRecordList()
I get:
Traceback (most recent call last):
File "example.py", line 43, in ?
prmidattrs = MyModule.SmRecordList()
File "win32com\gen_py\C85E7012-8B4F-11D1-8E20-00A02498EA3Cx0x1x0.py", line 1217, in __init__
TypeError: 'str' object is not callable
So either way, that isn't working either. I don't know enough about this stuff to figure it out.
-----Original Message-----
From: Paul Prescod [mailto:paul at prescod.net]
Sent: Monday, April 07, 2003 1:34 PM
To: Green, Gregory P
Cc: python-list at python.org
Subject: Re: Problem setting COM property using win32com
I don't know why that's happening, but I would suggest you take more
control of the instantiation by doing something like this:
from win32com.client.gencache import EnsureModule
MyModule = EnsureModule('{3BBEE982-742B-11D2-BD0A-00A024C36143}', 0, 1, 0)
reclist = MyModule.SmRecList()
In my recent COM project, I used the "dispatch" mechanism and pythoncom
was smart enough to pick up my gen_py'd module. But the mechanism above
is fine too. In fact, it is probably better by virtue of being more
explicit...
Green, Gregory P wrote:
> I don't think the gen_py class is being used:
>
> print obj: <COMObject SmRecList.SmRecordList>
>
> print obj.__class__: win32com.client.CDispatch
>
> print dir(obj): ['_ApplyTypes_', '_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_']
More information about the Python-list
mailing list