Nithin Mohan Nithin Mohan -4 years ago 139
Python Question

Close excel without VBA alert in python

I am using python win32com library to read an excel file. Following is the snippet I use.

import win32com.client

excel = win32com.client.Dispatch('Excel.Application')
workbook = excel.Workbooks.Open("path.xlsm")
s=workbook.Sheets('Request')
print(str(s.Cells(10,18)).replace(" ","").lower())
workbook.Close()


On calling close, a VBA warning pops up. And the program execution stops till I press'OK'. Please help me in ignoring this warning?
I have tried
excel.DisplayAlerts = False
, which didn't help

Answer Source

have you tried workbook.Close(False) ?

excel.EnableEvents = False will disable Excel Macros.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download