MATLAB: How to disable the ‘Do you want to save…’ message box that pops up in Excel when I invoke a save using ActiveX in MATLAB 7.7 (R2008b)

activexexcelMATLAB

I am using ActiveX to connect to Excel using a workflow similar to the one below:
Excel = actxserver('Excel.Application');
Workbook = Excel.Workbooks;.
When I save the workbook using the below code:
invoke(Workbook,'SaveAs',[pwd '\' filename]);
I get a message box that pops up in Excel asking me to confirm if I would like to save the Workbook as what I have specified in variable 'filename'. How do I disable this message box and just force Excel to save it as what I have specified?

Best Answer

To disable the message box that pops up in Excel, please set the DisplayAlerts property of the ActiveX connection to 'false' as shown in the following code:
Excel = actxserver('Excel.Application');
Excel.DisplayAlerts = 0;