Hi,

I have been working thru the 'Python Programming on Win32' book by M.
Hammond in an attempt to get up to speed on Python COM programming. I am
trying to do some simple output to Excel from a Turbogears application.

I am using Microsoft Excel 2003.

I have run into an issue using the Cells method or property when trying
to use the Excel examples in the book. Here is the console trace:

>>> from win32com.client import Dispatch
>>> xlApp = Dispatch("Excel.Application")
>>> actvSht = xlApp.ActiveSheet
>>> actvSht.Cells(1,1).Value
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"c:\python24\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-0
00000000046x9x1x0.py", line 9235, in __call__
    , DirectObject)
  File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line
446, in _ApplyTypes_
    return self._get_good_object_(
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
>>>

The range property does work.

>>> actvSht.Range("A1").Value
922.0
>>>

I have Googled for answers and also read the COM sections of the book.
It appears that because the 'Cells' string identifies a COM property and
a COM methods on the same ActiveSheet object. The COM property and COM
method are differentiated by their signatures but the python com library
cannot distinguish between them so the Cells(1,1) call above generates
the error. 

There was some discussion about wrapping the method in the Type Library
or that methods would be wrapped with a prefix of Get and the Property
would be left unmodified. How do I generate such an object.

The other issue I have is that I do not see the COM methods or
Properties when I do help(object) in the Python console.

>>> ar = actvSht.Range("A1:A10")
>>> help(ar)

... Long list of Standard Python methods e.g __eq__

>>>

Can anyone shed light on these two problems ?

Thanks

Tom
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to