Running excel macros with matlab activex

5 views (last 30 days)
Michael Joslin
Michael Joslin on 7 Jan 2013
I have a program that takes all of the info stored in the UserData of blocks and writes it to an excel spreadsheet. The spreadsheet I am writing to is a template made by soemone else that has many macros. Is it possible to run one of these macros using activex commands? For example one of the macros takes the value of block and adds it to a library for later comparisons, I want to be able to run this macro as I add the info so I don't have to go into the spread sheet and run it after my matlab prgram is done.

Answers (1)

Image Analyst
Image Analyst on 7 Jan 2013
If you open up Excel, record a new macro and run the other macro, what does it say? If you edit that macro and see what it says, then the ActiveX commands are fairly similar (though not always identical) to the code you'll see in the VBA macro in Excel. For example you may see something like
Application.Run "Book1!Macro1"
in the Excel macro. So the ActiveX command might be something like
Excel.Run('"Book1!Macro1"');
I don't know - I haven't tested this particular case but that's the process. You might go here for additional ActiveX help: http://msdn.microsoft.com/en-us/library/bb259457%28v=office.12%29.aspx

Products

Community Treasure Hunt

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

Start Hunting!