Distribute Add-Ins and Integrate Into Microsoft Excel
Integration Process Overview
Each MATLAB® Compiler™ component is built as a COM object that you can access from Microsoft® Excel® through Microsoft Visual Basic® for Applications (VBA). You can integrate the MATLAB Compiler components into Excel using the VBA programming environment.
For general information on programming in Visual Basic, refer to the VBA documentation provided with Excel.
Key Tasks for Microsoft Excel End User
|Verify that you have received all necessary files from the MATLAB programmer.||Files To Distribute To End Users|
|Verify registry permissions for the add-in file and associated DLL component.||Add-In and COM Component Registration|
|Execute your generated functions and create macros.||Execute Functions and Create Macros|
|Install MATLAB Runtime on target systems and update system paths.||Install and Configure MATLAB Runtime|
|Use the Excel add-in.||Add-In Installation and Distribution|
Files To Distribute To End Users
After you create your Excel add-in, distribute the generated installer to your end user. The installer installs the packaged add-in and MATLAB Runtime.
If you do not create an installer, distribute the files that the Library Compiler
generates in the
for_redistribution_files_only folder. For a list
of files generated in each folder, see Files Generated After Packaging MATLAB Functions.
Add-In and COM Component Registration
COM components are used in both MATLAB Compiler and MATLAB Compiler SDK™, therefore some of the instructions relating to building and packaging COM components and add-ins can be shared between products.
When you create your COM component, it is registered in either
based on your log-in privileges.
If you find you need to change your run-time permissions due to security standards imposed by Microsoft or your installation, you can do one of the following before deploying your COM component or add-in:
Log on as
administratorbefore running your COM component or add-in
Run the following
mwregsvrcommand prior to running your COM component or add-in, as follows:where:
mwregsvr [/u] [/s] [/useronly] project_name.dll
/uallows any user to unregister a COM component or add-in for this server
/sruns this command silently, generating no messages. This is helpful for use in silent installations.
/useronlyallows only the currently logged-in user to run the COM component or add-in on this server
If your COM component is registered in the
it will not be visible to Windows Vista™ or Windows® 7 users
administrator on systems with UAC (User
Access Control) enabled.
If you register a component to the
under Windows 7 or Windows Vista, your COM component may fail
to load when running with elevated (
If this occurs, do the following to re-register the component
LOCAL MACHINE hive:
Unregister the component with this command:
mwregsvr /u /useronly my_dll.dll
Reregister the component to the
LOCAL MACHINEhive with this command:
Add-In Installation and Distribution
Excel add-ins are written directly to the
Compiler, you and your end users install them exactly as you install the
Function Wizard in Installation of the Function Wizard.
Call Add-In Code from Excel Spreadsheet
To run the executable code from a cell in the Excel spreadsheet, invoke the add-in name with a method call. For
example, if you deployed a piece of MATLAB code called
mymagic.m, or a figure called
mymagic.fig, you invoke that code by entering the
following in a cell in the spreadsheet:
If the method call does not evaluate immediately, press Ctrl, Shift, and Enter simultaneously.