4

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()
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Joe Chan
  • 133
  • 3
  • 11

1 Answers1

9
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()
Xukrao
  • 8,003
  • 5
  • 26
  • 52