MATLAB: Can you call an Excel Add-in function, created with MATLAB Compiler SDK, from other VBA projects in Excel

addadd-inaddincompilerexcelinMATLABsdkvba

I created an Excel Add-in using MATLAB Compiler SDK and included it in my Excel workbook. I can now use the functions of the Add-in via the function bar in Excel. Is it also possible to call the functions of the Add-in from other VBA projects programmatically?

Best Answer

Yes, you can call the Excel Add-in function programmatically from other VBA projects. One way to do this is by using "Application.Run", as shown below:
Function myFunc(Optional Arg1 As Variant, Optional Arg2 As Variant) As Variant
myFunc = Application.Run("'myAddinFunc.xla'!myAddinFunc", Arg1, Arg2)
End Function
Where:
- "myFunc" is a function in a separate VBA project
- "myAddinFunc.xla" is the VBA project containing the add-in function created with MATLAB Compiler SDK
- "myAddinFunc" is the function to call in the add-in created with MATLAB Compiler SDK
- "Arg1" and "Arg2" are the arguments to pass to the function