On 20/02/2006 10:15 PM, Tim Golden wrote:
> [John Machin]
>
> | > OK, given the workbook created in my previous post...
>
> [ ... snip more code ...]
>
> | 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?
>
> I swear this reads like the script of an educational children's
> programme! ;) But you're quite right to point out how scantily
> I read the original question and just dived for my keyboard.
>
> It's not clear to me what the "default" sheet is. What I didn't
> show in my code examples is the concept of the ActiveSheet which
> can be changed by calling a sheet's .Select method. When the
> workbook is saved, that active sheet is saved with it. (ie the
> activeness of one sheet is saved). Maybe that's the idea?
> [Do you think the OP's still reading?]
>
> <code>
> import win32com.client
>
> xl = win32com.client.Dispatch ("Excel.Application")
> wb = xl.Workbooks.Open ("c:/temp/test.xls")
> print wb.ActiveSheet.Name
> #
> # probably prints "First Sheet"
> #
> wb.Sheets ("Third Sheet").Select ()
> print wb.ActiveSheet.Name
> # prints "Third Sheet"
>
> wb.Save ()
> wb.Close ()
>
> wb = xl.Workbooks.Open ("c:/temp/test.xls")
> print wb.ActiveSheet.Name
> #
> # prints "Third Sheet"
> #
> </code>
>
> Any better?
>
> TJG
>
Tim, that's fantastic. Hold out your hand for the elephant stamp :-)
Is the OP still reading? Yes, I often wonder that too, when threads get
a bit long. But apart from moderate banter, we haven't got off his
topic, so let's hope he's hung in there, time zones permitting.
Cheers,
John
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32