Vote count:
0
A python 2.7 script, executed by Task Scheduler running on Windows Server 2012 (64 bit), ends without raising an exception at the point where it is opening an existing XLS file. Creating the Dispatch works fine (try/except not shown):
xlApp = win32com.client.DispatchEx('Excel.Application')
but right after that:
try: log_message("Opening Excel Workbook object for the attachment using password '%s'" % email_found['PASSWORD']) workbook = xlApp.Workbooks.Open(attachment, False, False, None, email_found['PASSWORD']) log_message("Workbook opened, produced object with type '%s'" % type(workbook).name) except Exception, e: log_message("Exception opening workbook") message = "Exception raised : %s" % str(e) log_message(message, 'ERROR') xlApp.Quit() return 22
log_message() writes to a log file and optionally sends an email. The first message appears, and that's the end of the log file. Excel shows up as running in Task Manager, and the task shows as running in Task Scheduler.
The very same script, when run in a command shell by the same user, completes successfully. The very same script, when run in Task Scheduler on a Win7 box, completes successfully.
Other information:
- The user whose account runs the task is a local administrator. I have tried two such users, and the same thing happens for both.
- There is only the one instance of Excel (2010) installed on the box.
- I found some posts that mention the necessity of having one or the other (or both) of these directories:
C:\Windows\SysWOW64\config\systemprofile\Desktop
C:\Windows\System32\config\systemprofile\Desktop
Both are present for me (they're empty). - I'm running this script on Windows, rather than using xlrd on our preferred Linux platform, because xlrd does not support password protected XLS files. The XLS file is sent to us every week day by a client.
Any suggestions are most welcome, and thanks in advance.
Python script reading an Excel file stops executing in Task Manager
Aucun commentaire:
Enregistrer un commentaire