Problem setting COM property using win32com

Greg Green gregory.p.green at boeing.com
Sat Apr 5 17:51:30 EST 2003


I have a commercial com api that I'm trying to use with python. I am
trying to set a property of the com object. The property is called
Value, and I know enough to use the SetValue function. But that
doesn't work.

Here is the code:
    attrs.SetValue("CN_ID", 0, "0000005")

Here is the error:
Traceback (most recent call last):
  File "example.py", line 49, in ?
    prmidattrs.SetValue("CN_ID", 0, "0000005")
  File "C:\PYTHON22\lib\site-packages\win32com\client\dynamic.py", line 438, in __getattr__
    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: SmRecList.SmRecordList.SetValue

If I look at the makepy generated module, I see the method.

	# The method SetValue is actually a property, but must be used as a method to correctly pass the arguments
	def SetValue(self, HeaderName=defaultNamedNotOptArg, RecordIndex=defaultNamedNotOptArg, arg2=defaultUnnamedArg):
		"""Retrieves, sets or adds a value to the object. Specified by header name and record index."""
		return self._oleobj_.InvokeTypes(0x1, LCID, 4, (24, 0), ((8, 1), (3, 1), (12, 1)),HeaderName, RecordIndex, arg2)

Any ideas?

-- 

Greg Green




More information about the Python-list mailing list