Open MS Excel from Matlab

Is there a way to make Matlab open Excel files directly in MS Excel? I don't want to just read the data, but physically open MS Excel. I have a script that processes some data and stores it in .xlsm. This .xlsm contains the auto_open macro that generates the report and saves it to another .xls. I want the process to be as automatic as possible. For now, when the matlab script ends, the .xlsm file has to be opened manually. Can this be done via Matlab? (The .m and .xlsm file are in the same folder.)


source to share

3 answers

The easiest way to open (but not close) an Excel file is using WINOPEN :





Excel has a powerful COM interface that allows you to control it from another application.

See here where the Maclab side is.

And here's an example to put it all together ...

or here's another example



Yes it is possible. Matlab can use the Excel Automation interface for this and similar tasks. The following code loads Excel and then loads the workbook:

    w = actxserver('Excel.Application');     % Fails if Excel not installed
    w = [];

if ~isempty(w)
    % Your code here;


You will need to look at the Microsoft documentation for the Excel Automation interface to determine exactly what commands you need to send. Try running here . I used this technique to drive Word from Matlab to create a reporting document, but I have never used Excel this way, so unfortunately I cannot help you with gory details!



All Articles