Microsoft Office 2000/Visual Basic Programmer's Guide   

Creating COM Add-ins for Multiple Applications

Each add-in designer in your project creates an add-in that can run in only one application. To create a COM add-in that's available to more than one application, you create a new add-in designer for each application that you want to use the add-in, and then customize the add-in designer for each application.

For example, suppose that you want to create an add-in for Word and PowerPoint that creates an organizational chart from a table in a database and inserts the chart into the document or slide. You would begin by making sure there is an add-in designer for Word and one for PowerPoint.

To add a new add-in designer

  1. On the Project menu in Visual Basic 6.0, click Add Add-in Class.

    If the Add Add-in Class command does not appear on the Project menu, click Components on the Project menu to open the Components dialog box. Click the Designers tab, and select the Add-in Class check box.

  2. Change the add-in designer's Name property setting in the Properties window. It may be helpful to indicate in the name of the add-in designer which designer goes with which application. For example, the add-in designer for Excel in the Image Gallery project is named dsrImageExcel.

  3. Save the add-in designer file.

Important   When you add an add-in designer to your project, you must make sure that the Public property for the add-in designer is set to True. This property appears in the Visual Basic 6.0 Properties window. If this property is set to False for an add-in designer that appears in the project, the COM add-in will not be registered for the host application designated by that add-in designer.

Essentially, each add-in designer in the Visual Basic project represents a separate add-in that can run in only one Office application. The resulting DLL can contain multiple add-ins that share forms, modules, and class modules, but are targeted for different applications.

Note   If your COM add-in will run in more than one application, it's a good idea to set the threading model for the project to Apartment Threaded. Apartment threading can enhance the performance of add-ins that run in more than one application and that involve lengthy operations. You can set the threading model on the General tab of the Project Properties dialog box, available on the Project menu in Visual Basic 6.0. For more information about threading models, refer to the Visual Basic 6.0 documentation.