[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

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to