Excel Macro List from inside Matlab

Problem: I have a excel ile written by others. I need to run the VBA macro from withng Matlab.
I am not certain the macro name is correct. It is the name in the VBA editor. It is a botton click command macro in the spread sheet.
runFile = [filelist(i).folder,'\',filelist(i).name] ;
% Create object.
ExcelApp = actxserver('Excel.Application');
% Show window (optional).
ExcelApp.Visible = 1;
% Open file located in the current folder.
ExcelApp.Workbooks.Open(fullfile(runFile));
workbook = ExcelApp.Workbooks.Open(fullfile(runFile));
% Run Macro, defined in the module "Module1" with no parameters and a return value.
ExcelApp.Run('btnAnalysis');
>>> When running
Error using COM.Excel_Application/Run
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Cannot run the macro 'btnAnalysis'. The macro may not be available in this workbook or all macros may be disabled.
Help File: xlmain11.chm
Help Context ID: 0

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Export to MATLAB에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2021년 10월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by