How to use an Excel Add In Function in MATLAB?

6 vues (au cours des 30 derniers jours)
Vivian
Vivian le 7 Déc 2017
Commenté : Guillaume le 3 Jan 2018
I have an Excel Add In function that I would like to use in MATLAB. I'm not sure if there's a way to import it or would I have to hard code what the add in function does into MATLAB?

Réponses (1)

Kay Baumann
Kay Baumann le 3 Jan 2018
Modifié(e) : Kay Baumann le 3 Jan 2018
Hi Vivian,
unfortunately I can only give you a couple of hints on how to possibly do this but maybe you can use them as a starting off point.
1. Try using a COM object:
It is possible to create an Excel object via a COM Server
ExcelApp = actxserver('Excel.Application')
After that you can access methods and attributes of the object. For example to create new workbooks.
There is also an AddIns method which returns a collection object of Add-Ins in the excel dialog box.
To display paths in the collection to the Command Window use following code:
ExcelApp = actxserver('Excel.Application');
AddIns = ExcelApp.AddIns();
for i = 1:AddIns.Count
CurrAddIn = AddIns.Item(i);
disp(CurrAddIn.FullName)
end
ExcelApp.delete
For documentation on the excel objects visit: object-model-excel-vba-reference
Maybe you can figure out a way from that.
2. Employ MATLAB Production Server:
You can have a look at the MATLAB Production Server which includes Excel integration and has a subpage on how to install excel addins. Take this with a grain of salt though cause I have no experience with this product cause it needs its own license. So I only can assume this is capable of what you asked, from a glance over the documentation.
3. Re-implement the functionality in MATLAB:
Like you already said it could be, that depending on the complexity of the AddIns functionality, that writing it in MATLAB Code could be faster and/or cheaper for you. I for example find it sometimes hard to efficiently figure out how to use excel objects in MATLAB correctly and it can yield its own unexpected quirks.
  1 commentaire
Guillaume
Guillaume le 3 Jan 2018
A few clarifications:
There is no way to use an excel add-in directly from matlab. The only way to use that add-in would be with option 1 in Kay's answer but you would be in effect using matlab to control excel in order to use the add-in in excel. Data transmission to/from the add-in would most likely be by writing/reading to spreadsheets from matlab. This is all doable and not particularly complicated if you are familiar with excel VBA. If not, you'll have a stiff learning curve.
As far as I understand, Matlab Production Server enables you to write excel add-ins that can interact with matlab code running on the server. It does not enable you to use excel add-ins within matlab.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by