I’m working on a vb.net console app that opens a number of spreadsheets one by one, reads in a couple cells and closes the file.
Some of the spreadsheets have formulas that Excel recalculates when I open the file, and I’m getting a dialog box asking me if I want to save changes to the spreadsheet when I close it.
Message: ‘Do you want to save the changes to myfile.xls? Microsoft Office Excel recalculates formulas when opening files last saved by an earlier version of Excel’
How do I automatically decline that dialog box?
Dim newCBD As New CBD Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet xlApp = New Excel.ApplicationClass xlWorkBook = xlApp.Workbooks.Open(myFile) xlWorkSheet = xlWorkBook.Worksheets(1) ...do a bunch of junk here xlWorkBook.Close() xlApp.Quit()
Thanks!
You need to supply a False parameter on the Close method
From Excel VBA Help: