我正在使用 pywin32 运行 VBA 宏,但是当完成时我在屏幕上有一个弹出窗口,然后如果我不单击它就无法继续执行我的代码。知道如何处理吗?
我的代码:
def excel_vba(file):
excel= win32.gencache.EnsureDispatch('Excel.Application')
# Hacemos el excel visible para que no se quede en segundo plano
excel.Visible = True
# Abrimos nuestro archivo
wb = excel.Workbooks.Open(file)
# Ejecucion de la macro
excel.Application.Run('\'' + file + '\'' + "!Macro.Sheet.Button")
"""My code is stuck right here till I press the dialog box"""
# Cerramos el COM Object
wb.Save()
excel.Application.Quit()
del excel
file = "H:\Test.xls"
excel_vba(file)```
我发现解决方案只是从可见变为不可见:
excel.Visible = False
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句