Exporting from Matlab to excel with macro.
Mostra commenti meno recenti
I have matrix which I have to add in excel file. Excel file looks like in picture. With StartLoft, than StartCurve, than matrix which needs to be added, than EndCurve, EndLoft, End.

In this excel I should have embedded macro file to just open excel after starting matlab code, and run macro, without adding it additionaly. Is this possible? Macro code for excel is attached.
4 Commenti
Guillaume
il 10 Lug 2018
Is this any different from your previous question with the exact same title, which you've completely ignored?
Guillaume
il 10 Lug 2018
In addition, the first lines of the text file you've attached has this:
COPYRIGHT DASSAULT SYSTEMES 2001
Have you got permission from the copyright holder to post the file here?
Matija Kosak
il 10 Lug 2018
Matija Kosak
il 10 Lug 2018
Risposta accettata
Più risposte (1)
Sayyed Ahmad
il 10 Lug 2018
you have to use activeX in matlab to start Excel
e = actxserver('excel.application');
e.visible=1;
%%new Woorkbook
eWorkbooks = get(e, 'Workbooks');
% neuWB=Add(eWorkbooks)
%%open a Workbook
neuWB=eWorkbooks.Open('YourExcelFile.xlsm');
Now you kann start your Macro in Excel
%%makro starten
e.ExecuteExcel4Macro(['!NameOfModule.NameOfSub(' INPUT_ValuesFromMatlabInExcel ')']);
%%save your work in excel
neuWB.Save();
neuWB.Saved = 1;
neuWB.Close;
%%excel clear and close
e.Quit;
e.delete
I hope that is what you need!
cheers Ahmad
2 Commenti
Guillaume
il 10 Lug 2018
Note that this requires that the macro already exists in the workbook and that macros are enabled. In most recent versions of Excel, if you have the default security settings, unless the macro is signed, macros will be disabled.
I would not recommend lowering the security settings as macro viruses are still common.
Matija Kosak
il 10 Lug 2018
Categorie
Scopri di più su Spreadsheets in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!