> >>> 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-0 > 000-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.
Best I can tell, there is only a 'get' method for Cells - it returns a Range object, and any changes to the cells values would be done via that range object - so there is no way to 'set' the Cells property. I'm afraid I don't know your answer, and suspect it is something unique to Excel - hopefully someone else who uses Excel regularly will chime in. > 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__ > > >>> Just is a side effect of how 'help()' works. It is probably easy to fix this, but the COM support predates the builtin 'help' function, which is why wasn't made to work initially. Cheers, Mark
<<attachment: winmail.dat>>
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32