Newbie: returning dynamicly built lists (using win32com)
ptmcg at austin.rr._bogus_.com
Tue Jun 6 20:48:26 CEST 2006
"Ransom" <gyows at sbcglobal.net> wrote in message
news:1149613586.862299.125070 at u72g2000cwu.googlegroups.com...
> Very newb here, but my question will hopefully be obvious to someone.
> But when I try and put the output from the spreadsheet into
> a dynamic list after the TODO section thusly:
> outputlist = 
> return outputlist
> I get an error like:
> [<win32com.gen_py.Microsoft Excel 9.0 Object Library.Range instance at
1. First of all, this is not the code you are running. I know this because
the unbalanced parens wont even compile. It really doesn't help when you
ask for help, but post the wrong code.
2. What you are getting is NOT an error. Read it very carefully. What you
have added to outputlist is a Range object. Look into the Excel COM
documentation (you can open up VB from Excel by pressing Alt-F11, then open
the Object Browser to see the object API) for how to access the methods and
properties of an Excel Range. I'm guessing one of the properties Value,
Value2, Text, or Formula will give you what you want.
3. The reason your print statement appears to work is because print
implicitly applies the str method to objects, while applying the repr method
to contents of a list. So "print excel.ActiveSheet.Cells(32,6)" will output
"42" or whatever - for grins, try "print
type(excel.ActiveSheet.Cells(32,6))" (taking care to insert enough parens
All that is gold does not glitter, not all who wander are lost, don't judge
a book by its cover, or a variable by its output, etc...
More information about the Python-list