solved: win32com function<->propterty problem

Bernhard Reiter bernhard at alpha1.csd.uwm.edu
Sun May 2 15:55:54 EDT 1999


On 30 Apr 1999 04:26:34 GMT, Bernhard Reiter <bernhard at alpha1.csd.uwm.edu> wrote:

Thanks to Mark H. the problem dissolved:

Using the makepy script and looking in the source it generated,
I found the right function:

	SetValueAt(1,1,"new Value")

FYI
	Bernhard
(Oh Mark, it just comes into my mind: What if SetValueAt already
existed as OLE method? Will makepy then choose a different name?)

. My OLE object an instance of ISpssDataCells
. should have an array as property. From the SPSS documentation:
. 
.     ValueAt Property
. 	Returns or sets the value of the current data cell or row/column label. 
. 
.     Syntax
. 	object.ValueAt (row,column) [=value]
. 
.     Settings
. 	row	Row index (Long)
. 	column	Column index (Long)
. 	value	Variant (String or Binary)
. 
. 
. Python win32com provides that as a function.
. And I can perfectly get the values like
. 	value=object.ValueAt(1,1)
. but setting ist a problem:
. 
. >>> d
. <win32com.gen_py.SPSS Pivot Table Type Library.ISpssDataCells>
. >>> d.ValueAt
. <method ISpssDataCells.ValueAt of ISpssDataCells instance at 1199f00>
. >>> d.ValueAt(1,1)
. >>> d.ValueAt(1,1)=123
. Error pulling apart exceptionTraceback (innermost last):
.   File "C:\Python\Pythonwin\pywin\framework\interact.py", line 345, in keyhandler_enter
.     message, (filename, lineno, offset, text) = exc_value
. ValueError: unpack sequence of wrong size
. SyntaxError: can't assign to function call
. 
. 
. The Python Com Browser shows me, that there are two entries in
. the Registered Spss Pivot Table Type Library, ISpssDataCells as
. function:
.     ValueAt - Function
. 	Dispatch ID=26
. 	Named Params ='row,col'
. 	Return Type ='Variant'
. 	Argument = 'Integer 4 (Flags=1)'
. 	Argument = 'Integer 4(Flags=1)'
. 	Function Kind ='Dispatch'
. 	Invoke Kind = 'Property Get'
. 	Number Optimal Params=0
.     ValueAt - Function
. 	Dispatch ID=26
. 	Named Params ='row,col'
. 	Return Type ='Void'
. 	Argument = 'Integer 4 (Flags=1)'
. 	Argument = 'Integer 4(Flags=1)'
. 	Argument = 'Variant (Flags=1)'
. 	Function Kind ='Dispatch'
. 	Invoke Kind = 'Property Put'
. 	Number Optimal Params=0
. 
. Okay, python seems to know about both possibilities, but how do
. I use them?




More information about the Python-list mailing list