Win32com不调度excel,说'服务器执行失败'

我最初的脚本是:

import win32com.client import os file1= r'C:\\Users\cevans\Desktop\models1\file.xlsm' def refresher(): if os.path.exists(file1): xl = win32com.client.Dispatch("Excel.Application") xl.Workbooks.Open(Filename=file1,ReadOnly=1) xl.Visible = True xl.Application.Run('Report_Tablerefresh1') xl.Workbooks(1).Close(SaveChanges=1) xl.Application.Quit() del xl refresher() 

当我尝试做一个简单的excel调度时,我遇到了这个错误,奇怪的是这个脚本已经运行好几个星期了,然后这个错误popup来了。 有什么build议么?

 Traceback (most recent call last): File "C:/Users/cevans/PycharmProjects/RigLocatorMapPull/Pipe_StorageRefresh.py", line 17, in <module> refresher() File "C:/Users/cevans/PycharmProjects/RigLocatorMapPull/Pipe_StorageRefresh.py", l ine 10, in refresher xl = win32com.client.Dispatch("Excel.Application") File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 104, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2146959355, 'Server execution failed', None, None) 

一个解决办法是重新启动Windows操作系统(做完整的重新安装),因为似乎与Windows操作系统registry与Excel中的错误。 我发现这是使用win32com的其他“服务器执行失败”types错误的原因。