Specifying Load Behavior

When a COM add-in has been properly registered, it is available to whatever applications are specified in the add-in designers that the project contains. The registered COM add-in display name appears in the COM Add-in dialog box; if it does not, click Add to browse for the add-in and add it to the list.

Selecting the check box next to an add-in in the COM Add-ins dialog box loads (connects) the add-in and makes it available to the user; clearing the check box unloads (disconnects) the add-in, and it cannot be run.

As the developer, you specify the default setting for when a COM add-in should be loaded. You do this in the Initial Load Behavior list in the add-in designer.

**Note   **Users can change this setting later by using the Add-in Manager.

You can specify that an add-in be loaded in one of the following ways:

  • Only when the user loads it in the COM Add-ins dialog box, or when Microsoft® Visual Basic® for Applications (VBA) code loads it by setting the Connect property of the corresponding COMAddIn object.
  • Every time the application starts.
  • The first time the application starts, so that it can create a toolbar button or menu item for itself. After that, the add-in is loaded only when the user requests it by clicking the menu item or button.

The following table describes the different settings for the Initial Load Behavior setting.

Initial Load Behavior setting Behavior
None The COM add-in is not loaded when the application boots. It can be loaded in the COM Add-ins dialog box or by setting the Connect property of the corresponding COMAddIn object.
Startup The add-in is loaded when the application boots. When the add-in is loaded, it remains loaded until it is explicitly unloaded.
Load on Demand 1 The add-in is not loaded until the user clicks the button or menu item that loads the add-in, or until a procedure sets its Connect property to True. In most cases, you will not set the initial load behavior to Load on Demand directly; you will set it to Load at Next Startup Only, and it will be set automatically to Load on Demand on subsequent boots of the host application.
Load at Next Startup Only 1 After the COM add-in has been registered, it loads as soon as the user runs the host application for the first time. The next time the user boots the application, the add-in is loaded on demand — that is, it does not load until the user clicks the button or menu item associated with the add-in, or through the COM Add-in dialog box.
Command line/Startup Add-in loads either when specifically invoked from a command-line parameter, when Visual Basic starts.
Command line Add-in loads only when specifically invoked from a command-line parameter.

1 Not available to add-ins developed using VBA.

See Also

Building COM Add-ins for Office Applications | Working with Add-in Designers | Writing Code in the Add-in Designer | Hooking a COM Add-in Up to a Command Bar Control | Debugging a COM Add-in | Making the DLL | Distributing COM Add-ins | COM Add-ins and Security