Export (0) Print
Expand All

Visual Basic Extensibility Reference

Visual Studio 6.0

OnDisconnection Method

See Also   Example   Applies To

Occurs when an add-in is disconnected from the Visual Basic IDE, either programmatically or through the Add-In Manager dialog box.

Syntax

object. IDTExtensibility_OnDisconnection (removemode As vbext_DisconnectMode, custom()As Variant)

The OnDisconnection method syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
removemode An enumerated value of type vbext_DisconnectMode, as specified in Settings.
custom() An array of variant expressions to hold user-defined data.

Settings

The settings for removemode (vbext_ConnectMode) are:

Constant Value Description
vbext_dm_HostShutdown 0 Add-in was removed by the add-in's host being closed.
vbext_dm_UserClosed 1 Add-in was removed by the user closing it.

Remarks

This method is part of the IDTExtensibility interface, which you should implement in the class that provides your connection object.

Important   Don't directly enter the syntax given above. Instead, use the Implements statement to generate the appropriate method template for the interface. To do this, in the Declarations section of the Class module that provides your add-in's connection object, enter:

Implements IDTExtensibility

After adding this line, you can then select IDTExtensibility from the module's Object drop down box. Select each method from the Procedure drop down to get the procedure template shown above in Syntax. Notice that the necessary code is automatically added to the Class module.

An interface's methods are exposed through the Implements statement. When the above syntax is entered in the Declarations section of the Class module that handles an add-in's events, the interface's methods become available for your use through the module's Procedure and Object drop down boxes. To add the code to the module, select the method from the Procedure drop down box.

Note   While the OnDisconnection method is a method to the IDTExtensibility interface, to you as a Visual Basic programmer it acts and behaves like an event. In other words, when an add-in is disconnected from the Visual Basic IDE, either programmatically or through the Add-In Manager dialog box, any code in the OnDisconnection method automatically occurs, just as if it were an event procedure.

Important   Since an interface is a contract between an object and Visual Basic, you must be sure to implement all of the methods in the interface. This means that all four IDTExtensibility interface methods are present in your Class module, each containing at least one executable statement. This can consist of as little as a single remark statement, but they must each contain at least one executable statement to prevent the compiler from removing them as empty procedures.

Show:
© 2015 Microsoft