[python-win32] Python and Excel via Cron
Jd H
pyth_ora at yahoo.com
Wed Nov 21 20:13:41 CET 2007
Hello,
I have the below python code which opens an excel sheet, runs a macro then save the file. When run from python it runs perfectly. Code is below. File name is test.py
<<<
from win32com.client import Dispatch
myExcel = Dispatch('Excel.Application')
myExcel.Visible = 1
myExcel.Workbooks.Add('C:\Python24\test.xls')
myExcel.Workbooks.Add('C:\Python24\macro.XLA')
myExcel.Run('Macro1')
myExcel.Application.DisplayAlerts = False
myExcel.ActiveWorkbook.SaveAs('C:\Python24\test.xls')
myExcel.Quit()
>>>
When run from cron, it fails at line 3 when it opens the file with below message:
Traceback (most recent call last):
File "c:\Python24\test.py", line 20, in ?
jd.Workbooks.Add('C:\Python24\test.xls')
File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 496, in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: Excel.Application.Workbooks
Any ideas how to resolve this?
Thanks, JD
---------------------------------
Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20071121/3d1b32ee/attachment.htm
More information about the python-win32
mailing list