필터 지우기
필터 지우기

Issues in Running VBA macros programmatically from Matlab

조회 수: 5 (최근 30일)
Vish
Vish 2024년 7월 31일
댓글: Vish 2024년 8월 1일
Hello,
When I try to open my VBA macro enabled excel directly and run the macro within excel, it works fine. However, when I try to do the same operation using Matlab script, it shoots these error messages. Does anyone has any idea?
% Test Script VBA Code access and run
ExcelApp = actxserver('Excel.Application'); % Create object
ExcelApp.Visible = 1; % Show window (optional).
macrobook = ExcelApp.Workbooks.Open(fullfile('C:\Pro','\Test.xlsm')); % Open file
retVal = ExcelApp.Run('Macro1'); % Run Macro1
I have checked my macro settings in excel and they are all enabled:
I have also attached a simple macro enabled file example.

채택된 답변

dpb
dpb 2024년 7월 31일
Just ran a simple test here and no problems...
I have had issues in the past with the new MS security settings are much more aggressive than used to be; particularly had trouble if the workbook came from the network drive and tried to work on a local copy; it would disable macros regardless.(*)
Had to go into Trust Center and add trusted locations to include the network for trusted documents as well as just checking the macro settings.
(*) Just discovered that the test ran while the workbook was still open after writing the little macro; when I closed it and reopened it, the "Enable VBA macros..." checkbox was unchecked again so had to physically check it yet again. Be sure it really is allowed and not just letting you get by because you're in the developer mode and writing the macro.
  댓글 수: 1
Vish
Vish 2024년 8월 1일
Indeed it was the MS security settings as some of them were controlled by my organization. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Export to MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by