MATLAB Answers

Why does Microsoft Excel generate the message "Microsoft Excel is waiting for another application to complete an OLE action." when I use Spreadsheet Link EX?

27 views (last 30 days)
I am using Spreadsheet Link EX functions in an Excel VBA macro. When I use the function MLEVALSTRING to execute a MATLAB function that runs for long duration, Excel displays a dialog box containing the following error message:
Microsoft Excel is waiting for another application to complete an OLE action.
After clicking the OK button on the dialog, the same dialog box reappears. To continue to use my application, I have to click OK on each new dialog box until MATLAB completes execution.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 15 Jun 2018
Edited: MathWorks Support Team on 15 Jun 2018
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.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.