Executing an Excel Add in from MATLAB

I am having issues executing an excel add in within a MATLAB script. I want to execute the excel add in (.xla) that requires an input function, and return the results from the add in on each iteration of a FOR loop into an array of values. I have been able to open excel and initiate the process using the actxserver(Excel.Application) function.
This is the basic modified code to activate the excel communication from the function reference:
e = actxserver('Excel.Application');
eWorkbook = e.Workbooks.Add;
e.Visible = 1;
eSheets = e.ActiveWorkbook.Sheets;
eSheet1 = esheets.get('Item', 1);
eSheet1.Activate;
eActiveSheetRange = e.ActiveSheet.get('Range', 'A1');
A = 'Add-in Function Input';
% Send add in input function to excel cell
eActiveSheetRange.Value = A;
% Return Add-in output and display
eActiveSheetRange.Value
Quit(e);
delete(e);
Using the add in within excel with the add in running would just require entering "=add in function" in cell A1 and the result of the add-in would return to cell A1. I want to simulate this process from MATLAB. So far I have been able to get excel open and the input for the macro is entered into cell A1, but the Add in is not executed and therefore the output not returned to MATLAB.
Any suggestions for executing this would be greatly appreciated. Also if there is a way to directly execute the add-in file (sending the function inputs and returning the output) without going through the excel interface that would be the preferred method.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

제품

질문:

2015년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by