how to run a Macro from excel in MATLAB
27 次查看(过去 30 天)
显示 更早的评论
Hello ,
i have a macro in excel programed in Visual Basic. I need to run it from MATLAB or coding it again in MATLAB language. How can i do it automatically?
I have MATLAB R2013b
Thank you so much!
0 个评论
回答(2 个)
Guillaume
2019-3-15
编辑:Guillaume
2019-3-15
It's going to be something like:
excel = actxserver('Excel.Application');
excel.Workbooks.Open('C:\somewhere\someexcelfilewithmacro.xlsx')
excel.Run('NameOfMacro');
excel.Quit; %when done
Of course, it's likely that you need more but with so little details it's unknown what that would be.
"or coding it again in MATLAB language".
There's no translator form VB to matlab. You'll have to write the code yourself.
However, this begs the question: why don't you run the macro directly from excel since it's already working there.
Girish babu P
2020-2-26
ExcelApp = actxserver('Excel.Application');
ExcelApp.Visible = 1;
ExcelApp.Workbooks.Open(fullfile(pwd,'\filename.xls'));
ExcelApp.Run('ThisWorkBook.Macro1');
ExcelApp.Quit;
ExcelApp.release;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!