[python-win32] Excel automation
Tim Golden
tim.golden at viacom-outdoor.co.uk
Wed Jun 15 15:30:51 CEST 2005
[Peter Jessop]
| Hi Tim
| Thanks for your quick response.
| I had determined that putting none zero values did not provoke the
| error, but did not realise the reason.
| However c.Offset (2, 2) should change the active cell (1 down and 1
| right, if it is 1-based), but it doesn't
|
| Regards
|
| Peter
May be a misunderstanding on your part. According to MS:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/owcvba10/html/ocproOffset.asp
and from my own experimentation, Offset doesn't affect which
cell is active, but merely returns *another* cell, relative
to the one you started with, which in your example is the
Active cell.
In other words, if you run this code, one line
at a time, you will see A1 with "Active 1" in
it, then B2 with "Active offset by (2,2)" in
it, and then B2 (the *new* active cell) with
"New active cell" in it.
<code>
from win32com.client import Dispatch
xl = Dispatch ("Excel.Application")
xl.Visible = True
xl.Workbooks.Add ()
active_cell = xl.ActiveCell
active_cell.Value = 'Active 1'
offset_cell = active_cell.Offset (2, 2)
offset_cell.Value = 'Active offset by (2,2)'
offset_cell.Activate ()
xl.ActiveCell.Value = 'New active cell'
</code>
HTH
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
________________________________________________________________________
More information about the Python-win32
mailing list