how to run a Macro from excel in MATLAB
조회 수: 12 (최근 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 Export to MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!