[python-win32] excel access...

Jeff Shannon jeff at ccvcorp.com
Mon Aug 25 11:54:39 EDT 2003


Christopher Quinn wrote:
> hello list.
> 
> i'm making a first foray into the windows world and using pythonCOM to 
> access fields of an excel spreadsheet.
> all seemed ok till i inquired the value of a cell containing a function 
> which retrieved in turn it's value over DDE from another application (a 
> stock price feed).
> i opened the spreadsheet with the update option set and so expected 
> excel to deliver a real result. unfortunately it returns -2146826259 
> every time.
> my question then is: should i be doing something other than 
> Cells(x,y).Value  to extract the data at some instant?

It's been quite some time since I really looked at this, and I never 
did get around to actually working on automating the use of functions, 
but I believe that Excel uses a field other than Value to store 
functions.  I suspect that, for cells containing functions, the Value 
will always be  irrelevant.  You'll have to look in the VBA docs 
included in Excel to determine the function attribute name; I believe 
that there's also a way to prod the COM server into calling that 
function for you and returning a result.

Jeff Shannon
Technician/Programmer
Credit International




More information about the Python-win32 mailing list