MATLAB COM Builder    

Integrating the Component with Visual Basic for Applications

Having built your component, you can implement the necessary VBA code to integrate it into Excel. Follow these steps to open Excel and select the libraries you need to develop the add-in:

  1. Start Excel.
  2. From the Excel main menu, select Tools->Macro->Visual Basic Editor.
  3. When the Visual Basic Editor starts, select Tools->References to display the Project References Dialog. Check Fourier 1.0 Type Library and MWComUtil 1.0 Type Library on the list.

Creating the Main VB Code Module For the Application

The add-in requires some initialization code and some global variables to hold the application's state between function invocations. To achieve this, implement a Visual Basic code module to manage these tasks, as follows:

  1. Right-click on the VBAProject item in the project window and select Insert->Module from the pop-up menu.
  2. A new module appears under Modules in the VBA Project. In the module's property page, set the Name property to FourierMain. See the next figure.

Figure 4-5: VBA Project: Insert->Module

  1. Enter the following code in the FourierMain module:

  Building the Component Creating The Visual Basic Form