Start two instances of Matlab from Excel
3 次查看(过去 30 天)
显示 更早的评论
Here's the problem:
I have developed a tool where Excel acts as a front-end interface to send data to Matlab and execute a Matlab script (VBA code handles sending the data inputs and then calls a Matlab script). In some cases, the execution can take a very long time and I would like to create another instance of Excel that could also interact with Matlab.
I can launch another instance of Excel while the first one is busy running a script through Matlab. On this second instance however, when I click on that Matlab add-in to start Matlab, I get the following error message: "Microsoft Excel is waiting for another application to complete an OLE action".
Does that have anything to do with creating a shared automation server? How would that work?
Thanks
1 个评论
回答(1 个)
Ankitha Kollegal Arjun
2017-10-31
I understand that you are getting the error 'Microsoft Excel is waiting for another application to complete an OLE action.'
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:
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 个评论
Walter Roberson
2017-10-31
Good information, but I am not convinced this is the fundamental problem: I suspect that a new automation server did not get started and that it is waiting for the first (and only) to finish.
On the other hand, if the MATLAB routine being started is computation heavy, then the CPUs might be in use and starting up the second automation server might be slow.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Export to MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!