Filter löschen
Filter löschen

Start two instances of Matlab from Excel

1 Ansicht (letzte 30 Tage)
Jean Dupin
Jean Dupin am 24 Okt. 2017
Kommentiert: Jean Dupin am 31 Okt. 2017
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 Kommentar
Walter Roberson
Walter Roberson am 24 Okt. 2017
You could get that problem if the automation server is shared.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ankitha Kollegal Arjun
Ankitha Kollegal Arjun am 31 Okt. 2017
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 Kommentare
Walter Roberson
Walter Roberson am 31 Okt. 2017
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.
Jean Dupin
Jean Dupin am 31 Okt. 2017
Yes - the information above unfortunately doesn't address the issue here. I don't think the problem is due to a computation heavy script but rather, as you pointed out, to the inability to start a new MATLAB server from the add-in in the ribbon as it's waiting for the first one to finish.
Which brings me to this - instead of first opening MATLAB through the ribbon and then executing the VBA code that interacts with that session, can't I create directly a MATLAB instance/automation server in the VBA code?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Use COM Objects in MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by