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
>   
What does "run from python" mean??
>    
>   <<< 
>   
What's that "<<<"?? If you meant to type ">>>", don't type, COPY/PASTE!!
>   from win32com.client import Dispatch
>    
>   myExcel = Dispatch('Excel.Application')
>   myExcel.Visible = 1
>   myExcel.Workbooks.Add('C:\Python24\test.xls')
>   

1. Dunno how that can work without using raw string; '\t' is a TAB 
character ...
2. Storing data files in a software installation directory is not a good 
idea.
3. Python 2.4?

>   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:
>   
cron on Windows? cygwin?

>    
>   Traceback (most recent call last):
>     File "c:\Python24\test.py", line 20, in ?
>       jd.Workbooks.Add('C:\Python24\test.xls')
>   
NOT the same code as quoted above (line 3 vs line 20, myExcel vs jd)
>     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?
>    
More info required: what is your environment, what exactly are you 
doing, exact code that you are trying to execute.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to