MATLAB Excel Builder | ![]() ![]() |
Sub foo(y1 As Variant, y2 As Variant) Dim aClass As mycomponent.myclass Dim ytemp As MWArg Dim today As Date On Error Goto Handle_Error today = Now Set aClass = New mycomponent.myclass Set y1 = New MWArg y1.MWFlags.DataConversionFlags.OutputAsDate = True Call aClass.foo(2, ytemp, y2, today) y1 = ytemp Exit Sub Handle_Error: MsgBox(Err.Description) End Sub
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:
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 Usage Examples for a list of working code samples.
|
![]() | Component Information | When to Use a Formula Function or a Subroutine | ![]() |