On 20/02/2006 8:02 PM, Tim Golden wrote:
> [John Machin]
> |
> | On 20/02/2006 7:46 PM, Tim Golden wrote:
> | > [yeswanty devi]
> | >
> | > | Hello all,
> | > | if we have number of excel sheets in a workbook.can
> | > | we access a selected sheet in the workbook. when i try to
> | > | acces it always goes to the last sheet.
> | >
> | > I assume this is the kind of thing you want:
> | > (somewhat exaggerated example, but ...)
> | >
>
> [... snip ...]
>
> |
> | Errrmmm ... I got the impression that the OP wanted to access a
> | particular sheet in an existing workbook, not to create a new
> | workbook.
>
> I guessed; but I usually try to make my examples run
> on their own two feet (or something!) if only so I
> can test the thing before posting. That's the only
> reason I created the book before selecting the sheets.
> I admit I do assume the existence of c:\temp.
>
> Good point about the names; I didn't think of that.
>
> OK, given the workbook created in my previous post...
>
> <code>
> import win32com.client
>
> xl = win32com.client.Dispatch ("Excel.Application")
> wb = xl.Workbooks.Open ("c:\\temp\\test.xls")
>
> sheet0 = wb.Sheets ("First sheet") # or wb.Sheets[0]
> sheet1 = wb.Sheets ("Second sheet") # or wb.Sheets[1]
> #
> # etc.
> #
>
> wb.Close ()
> xl.Quit ()
>
> </code>
>
> TJG
>
OK, great, Tim, we're almost there :-)
"when i try to acces it always goes to the last sheet." ... looks like
the OP wants the default sheet to point to some sheet other than the
last sheet; ho wdo we do that?
Cheers,
John
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32