Reputation: 143
When I do xl.Quit(), Excel always pops up with a prompt that ask whether or not I want to save. How do tell it I don't want to save?
xl = Dispatch('Excel.Application')
xl.Workbooks.Open('New Workbook.xlsx')
# do some stuff
xl.Quit()
Upvotes: 5
Views: 6938
Reputation: 8633
from win32com.client import Dispatch
# Start excel application
xl = Dispatch('Excel.Application')
# Open existing excel file
book = xl.Workbooks.Open('workbook.xlsx')
# Some arbitrary excel operations ...
# Close excel application without saving file
book.Close(SaveChanges=False)
xl.Quit()
Upvotes: 9