run excel macro from simulink
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi All
I try to use MATLAB Function block to run Excel macro by using MATLAB Function block in Simulink. Below is my code:
function duty = fcn()
duty = zeros(1,1);
coder.extrinsic('actxserver')
excel = actxserver('Excel.Application')
excel.Workbooks.Open('D:\pso.xlsm')
excel.Run('Sheet1.run_pso');
excel.Quit;
end
However, error pop out as shown below:
Attempt to extract field 'Workbooks' from 'mxArray'.
Anyone can help me? Thank you.
3 Commenti
Kavya Vuriti
il 30 Mar 2020
Hi,
The error given arises when there are variables which are not initialized and assigned directly. I think the following code must work:
Workbook = excel.Workbooks.Open('D:\pso.xlsm');
excel.Run('Sheet1.run_pso');
excel.Quit;
If the error persists, could you share the excel file with the macro.
Risposte (0)
Vedere anche
Categorie
Scopri di più su MATLAB Functions in Microsoft Excel in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!