フィルターのクリア

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 Center および File ExchangeData 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