Share via


Accessing COM Add-ins in Visio

You can access COM add-ins in Microsoft® Visio® through the COM Add-Ins dialog box, or through Automation using the COMAddIns property of a Visio Application object or the COMAddIns collection and COMAddIn object from the Microsoft Office 10.0 object library.

In this section…

Viewing a List of Available COM Add-ins

Using the COMAddIns Property to Get Information about COM Add-ins

Viewing a List of Available COM Add-ins

You can view a list of the available COM add-ins in the COM Add-Ins dialog box in Microsoft Visio (on the Tools menu, point to Macros, and then click COM Add-Ins).

You can load (connect) or unload (disconnect) an add-in by selecting the check box next to it. Loading a COM add-in loads it into memory so you can work with it. Unloading an add-in removes it from memory; you cannot use the add-in until you load it again.

Note To be able to load and run COM add-ins in Visio, you'll need to make sure that the Enable COM add-ins check box is selected on the Advanced tab in the Options dialog box (on the Tools menu, click Options).

To view the list of available COM add-ins

  1. On the Tools menu, point to Macros, and then click COM Add-Ins.
  1. To add a new COM add-in to the list, click Add.
  • Clicking
  • Add
  • and selecting an add-in that does not appear in the list registers the add-in DLL (if it is not already registered) and adds the add-in to the list of available COM add-ins for Visio.
  1. To remove a COM add-in from the list, click Remove.
  • As with any other COM DLL, the add-in DLL is registered as a unique object on the system.
  • Additionally, information about the add-in is placed in another section of the registry to notify Visio (and other Office applications) that the add-in exists and should be used by Visio. This section is deleted when you remove an add-in from the list. The DLL itself remains registered, and if you add the add-in to the list again, the add-in's informational section is re-created in the registry.

Note You can add only DLLs that are COM add-ins to the list of available add-ins in the COM Add-Ins dialog box. Only add-ins registered for the application you are working in can be registered.

TOP

Using the COMAddIns Property to Get Information about COM Add-ins

Use the COMAddIns property of an Application object for information about all COM add-ins currently registered in Microsoft Visio.

To get information about the object returned by the COMAddIns property

  1. On the Tools menu, point to Macros, and then click Visual Basic Editor.
  1. On the View menu, click Object Browser.
  1. In the Project/Library list, click Office.
  • If you do not see the Office type library in the
  • Project/Library
  • list, on the
  • Tools
  • menu, click
  • References
  • , select the
  • Microsoft Office 10.0 Object Library
  • check box, and then click
  • OK
  • .
  1. Under Classes, examine the class named COMAddIns.

This following macro demonstrates using the COMAddIns property to list the COM add-ins registered with Visio:

Public Sub IterateCOMAddIns()     Dim myCOMAddIns As COMAddIns     Dim myCOMAddIn As COMAddIn

    'Get the set of COM add-ins     Set myCOMAddIns = Application.COMAddIns

    'List each COM add-in in the     'Immediate window     For Each myCOMAddIn In myCOMAddIns         Debug.Print myCOMAddIn.Description     Next End Sub

In addition to retrieving and changing information about COM add-ins using the COMAddIns collection and COMAddIn object, you can use the COMAddIns collection and the COMAddIn object to load and unload COM add-ins programmatically. For details about the COMAddIn object and COMAddIns collection, see the Microsoft Office Visual Basic Reference.