[python-win32] Python and Excel via Cron

bob gailer bgailer at alum.rpi.edu
Wed Nov 21 20:32:33 CET 2007


Jd H wrote:
> 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
cron on Windows??? I did not know Windows had cron!

"fails at line 3???" The traceback refers to line 20. Is there another 
test.py involved??

Let's start there? And post the other version of text.py for us.



More information about the python-win32 mailing list