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

Answers (0)

Categories

Products

Release

R2021a

Asked:

on 20 Oct 2021

Community Treasure Hunt

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

Start Hunting!