[python-win32] Unable to close Excel, error in dynamic.py

George Flaherty George.Flaherty at sas.com
Wed Feb 8 17:04:12 CET 2006


I have been messing around Excel, but when I run the following example I get an error?

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from win32com.client import Dispatch
>>> xlApp = Dispatch("Excel.Application")
>>> xlApp.Visible = 1
>>> xlApp.Workbooks.Add()
<COMObject Add>
>>> xlApp.ActiveSheet.Cells(1,1).Value = 'Python Rules!'
>>> xlApp.ActiveWorkbook.ActiveSheet.Cells(1,2).Value = 'Python Rules 2!'
>>> xlApp.Close(SaveChanges=0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\usr\python\Lib\site-packages\win32com\client\dynamic.py", line 489, in __getattr__
    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: Excel.Application.Close

In genaral the excel application does not close. I am pretty sure this has worked in the past, but I can't verify the python version and pywin version? Right now I am using py 2.4.2 and pywin build 205.

Thanks
-george







More information about the Python-win32 mailing list