3 4
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.
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
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.
Removing an add-in deletes the registry key that contains the name and load behavior of the add-in. The Windows registry contains information about a COM add-in in two places:
Note
Use the COMAddIns property of an Application object for information about all COM add-ins currently registered in Microsoft Visio.
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.
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.