I am using Microsoft Office Interop to edit some excel files and when I close them I use
outputExcelWorkBook.Close(false, paramMissing, paramMissing);
But a dialog box still comes up, even though I passed false
as the first parameter. I have also tried it with true
and giving it a file path as the second parameter but in both cases a dialog box comes up asking me if I want to save before closing. Can anyone tell me what's going on here?
This worked for me:
Initiate Excel
Open the workbook
Get the active sheet and make an edit (added "Text" to cell [2,2])
Close the workbook with a single parameter of true which means "save changes"
No dialog box is displayed.
Note: When I call Close without a parameter I am prompted to save changes.
Try setting the
Application.DisplayAlerts
property tofalse
. You may find it useful to set this property tofalse
for the majority of your automation routines. Remember to restore the previous value before returning.