excel表格服务器不响应,Win32com不调度excel,说'服务器执行失败' Excel 中文网...

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 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错误的原因。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值