如何在没有弹出消息的情况下平稳地运行代码?

时间:2019-06-16 08:10:08

标签: python-3.x

我正在运行python代码以刷新Excel中的数据连接。数据连接链接到Microsoft SQL。一切都可以顺利运行,但是,会弹出一条消息,提示“这将取消挂起的数据刷新。继续吗?”。我不确定这是什么,并且我不希望它弹出,因为我想使用任务计划程序运行代码。

我尝试使用代码来阻止来自Excel的警报,它可以工作,但是我的数据没有刷新。

import win32com.client

# Start an instance of Excel
xlapp = win32com.client.DispatchEx("Excel.Application")

# Open the workbook in said instance of Excel
wb = xlapp.workbooks.open(<link to location>)

# Optional, e.g. if you want to debug
# xlapp.Visible = True

# Refresh all data connections.
wb.RefreshAll()
wb.Save()

# Quit
xlapp.Quit()

“这将取消待处理的数据刷新。继续吗?”

选项为ok,取消或x

感谢您的帮助!

0 个答案:

没有答案
相关问题