User`s guide
3 Programming with Excel Builder Components
3-2
Overview
Each MATLAB Excel Builder component is built as a stand-alone COM object.
You access a component from Microsoft Excel through Visual Basic for
Applications (VBA). This section provides general information on how to
integrate MATLAB Excel Builder components into Excel using the VBA
programming environment. It assumes that you have a working knowledge of
VBA and is not intended to be a discussion on how to program in Visual Basic.
Refer to the VBA documentation provided with Excel for general programming
information.
You can easily integrate MATLAB Excel Builder components into a VBA
project by creating a simple code module with functions and/or subroutines
that load the necessary components, call methods as needed, and process any
errors. In general, you need to address seven items in any code written to use
MATLAB Excel Builder components:
• “When to Use a Formula Function or a Subroutine” on page 3-3
• “Initializing Excel Builder Libraries with Excel” on page 3-4
• “Creating an Instance of a Class” on page 3-6
• “Calling the Methods of a Class Instance” on page 3-9
• “Processing varargin and varargout Arguments” on page 3-11
• “Handling Errors During a Method Call” on page 3-13
• “Modifying Flags” on page 3-14
Note All code samples in this section are for illustration purposes and
reference a hypothetical class named
myclass contained in a component
named
mycomponent with a version number of 1.0. See Chapter 4, “Usage
Examples” for a list of working code samples.