This is the expected behavior for lengthy MATLAB operations, which can exceed Excel's timeout for COM Automation calls.
If you do not expect your operation to take more than a few minutes, it may be waiting for user input (for example, a string for INPUT or a key press for MORE). Check that your code executes without interaction in MATLAB.
If your MATLAB code takes longer than a few minutes, you can disable the Excel warning using the steps below:
1. To disable this warning for one MLEvalString call, edit your VBA code such that alerts are not displayed around the long MATLAB operation:
...
Application.DisplayAlerts = False
MLEvalString ("myLongOperation")
Application.DisplayAlerts = True
...
where myLongOperation is your MATLAB function.
You will need to configure Excel to use MATLAB functions within macros by adding a reference in the VBA environment, as described in 'Work with the Microsoft Visual Basic Editor' in the following documentation:
2. Alternatively, if using an older version of Excel prior to Excel 2000 that does not reset DisplayAlerts at the end of each macro, you can run this macro once to turn off all alerts:
Sub nomorewait()
Application.DisplayAlerts = False
End Sub
Please note: This approach significantly changes the behavior of Excel --- for example, Excel will no longer ask you to confirm actions that will cause you to lose data.
In some cases, the issue can be resolved by enabling macros in Excel as below:
Navigate to File->Options->Trust Center->Trust Center Settings
Select 'Macro Settings' from left panel and 'Enable all macros' radio button from the right panel to enable macros.
Best Answer