win32com.client.gencache.EnsureDispatch('Excel.Application') 不再工作
该代码不再执行任何操作来选择打开的工作簿。我读了一堆旧帖子,当“Dispatch”单独不再工作时,使用“gencache.EnsureDispatch”强制它工作。这不起作用似乎与更新到 Excel 2019(2016 年之前)有关。
有什么想法吗?
完整代码:
excel = win32.gencache.EnsureDispatch('Excel.Application')
print("Active WB:", excel.ActiveWorkbook.Name)
excel.DisplayAlerts = False
export_folder = export_folder.replace('/', '\\')
excel.ActiveWorkbook.SaveAs(Filename = export_folder + filename, FileFormat = 6)
excel.Application.Quit() #close out all excel windows
excel.DisplayAlerts = True
The code no longer does anything to select the open workbook. I read through a bunch of older posts that used the "gencache.EnsureDispatch" to force it to work when "Dispatch" alone was no longer working. This not working seems to be tied to updating to Excel 2019 (prior 2016).
Any ideas?
Full Code:
excel = win32.gencache.EnsureDispatch('Excel.Application')
print("Active WB:", excel.ActiveWorkbook.Name)
excel.DisplayAlerts = False
export_folder = export_folder.replace('/', '\\')
excel.ActiveWorkbook.SaveAs(Filename = export_folder + filename, FileFormat = 6)
excel.Application.Quit() #close out all excel windows
excel.DisplayAlerts = True
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论