[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 ________________________________________________________________________ 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