[python-win32] Excel automation
Tim Golden
tim.golden at viacom-outdoor.co.uk
Wed Jun 15 15:05:44 CEST 2005
[Peter Jessop]
| Running python 2.4.1 with pywin32-204 (2.4)
| I am new to Python so this is probably an oversite on my part.
| We are evaluating Python with the idea of replacing VBScript for
| system administration.
| I have been impressed with the capabilities of Python and in general
| have found it easy to pick up.
| Encountered the following problem with Excel.
|
[... snip error situation ...]
| >>> objExcel.ActiveCell.Offset(1,0).Activate
| Traceback (most recent call last):
| File "<stdin>", line 1, in ?
| File
| "C:\Python24\lib\site-packages\win32com\gen_py\00020813-0000-0
| 000-C000-00
| 0000000046x0x1x5.py", line 14615, in __call__
| , ColumnIndex)
| File
| "C:\Python24\Lib\site-packages\win32com\client\__init__.py",
| line 446, in
| _ApplyTypes_
| return self._get_good_object_(
| pywintypes.com_error: (-2147352567, 'Ocurri\xf3 una
| excepci\xf3n.', (0, None, No
| ne, None, 0, -2146827284), None)
|
| The problem occurs with both early and late binding.
Thanks for producing a reproducible situation, and the added
info about early/late binding. All I've done is to reproduce
at the interpreter, and then play around a bit, discovering
that the problem lies in the offset values, which want to
be 1-based and not zero-based. I don't know if this is a
bug or a feature, or what, but if you do this (following on
from your earlier code):
c = objExcel.ActiveCell
c01 = c.Offset (1, 0)
you get an error, whereas
c22 = c.Offset (2, 2)
is ok, and
c22.Value = 'XXX'
performs as expected.
I'm sure if you'd gone that little bit further with
your test case, you'd have reached the same point
pretty quickly.
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