09-18-2015 05:49 AM
I am writing an application that exports data to an Excel sheet by means of excel2000 instrument.I want to be able to suppress confirmation dialog box while saving a file over an existing one. The background is that the filename is choosen by the operator with FileSelectPopupEx, so if the file already exists the function automatically asks for a confirmation before exiting so an additional same dialog is annoying.
Based on this MSDN page, I experimented with ConflictResolution parameter in Excel_WorkbookSaveAs to no avail: the line I am using is this one but it keeps prompting me a confirmation dialog if the file already exists:
errChk (Excel_WorkbookSaveAs (ExcelWorkbookHandle, NULL, MyVariant, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, ExcelConst_xlNoChange, CA_VariantInt (ExcelConst_xlLocalSessionChanges), CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL));
Based on this post by kirkm I found that calling
errChk (Excel_SetProperty (ExcelAppHandle, NULL, Excel_AppDisplayAlerts, CAVT_BOOL, VFALSE));
I can suppress the dialog, but it suppresses all alerts that could be raised and it seems excessive to me. I wonder if anyone succeeded in hiding the dialog in Save As call.
09-18-2015 08:33 AM
09-21-2015 02:34 AM - edited 09-21-2015 02:35 AM
Well, the solution proposed there is simply to hide alerts before saving, so no way to have the parameter of Excel_WorkbookSaveAs working as it is supposed (?) to do. Hiding the alerts prevents messages despite the content of ConflictResolution parameter.
09-21-2015 08:24 AM
@RobertoBozzolo wrote:
Well, the solution proposed there is simply to hide alerts before saving, so no way to have the parameter of Excel_WorkbookSaveAs working as it is supposed (?) to do. Hiding the alerts prevents messages despite the content of ConflictResolution parameter.
Did you try it ?
09-21-2015 09:49 AM
Of course I did!