LoadBehavior Values
The LoadBehavior entry under the HKEY_CURRENT_USER/Software/Microsoft/Office/application name/Addins/add-in ID key contains a bitwise combination of values that specify the run time behavior of the add-in. The lowest order bit (values 0 and 1) indicates whether the add-in is currently unloaded or loaded. Other bits indicate when the application attempts to load the add-in.
Typically, the LoadBehavior entry is intended to be set to 0, 3, 9, or 16 (in decimal) when the add-in is installed on end user computers. By default, Visual Studio sets the LoadBehavior entry of your add-in to 3 when you build or publish it.
The following table lists all the possible values of the LoadBehavior entry. Some descriptions in this table refer to loading an add-in manually or programmatically. To load an add-in manually, select the check box next to the add-in in the COM Add-Ins dialog box in the application. To load an add-in programmatically, set the Connect property of the COMAddIn object that represents the add-in to true.
Value (in decimal) | Add-in status | Add-in load behavior | Description |
---|---|---|---|
0 | Unloaded | Do not load automatically | The application never tries to load the add-in automatically. The user can try to manually load the add-in, or the add-in can be loaded programmatically. If the add-in is successfully loaded, the LoadBehavior value remains 0, but the status of the add-in in the COM Add-ins dialog box is updated to indicate that the add-in is loaded. |
1 | Loaded | Do not load automatically | The application never tries to load the add-in automatically. The user can try to manually load the add-in, or the add-in can be loaded programmatically. Although the COM Add-ins dialog box indicates that the add-in is loaded after the application starts, the add-in isn't actually loaded until it is loaded manually or programmatically. If the application successfully loads the add-in, the LoadBehavior value changes to 0, and remains at 0 after the application closes. |
2 | Unloaded | Load at startup | The application does not try to load the add-in automatically. The user can try to manually load the add-in, or the add-in can be loaded programmatically. If the application successfully loads the add-in, the LoadBehavior value changes to 3, and remains at 3 after the application closes. |
3 | Loaded | Load at startup | The application tries to load the add-in when the application starts. This is the default value when you build or publish an add-in in Visual Studio. If the application successfully loads the add-in, the LoadBehavior value remains 3. If an error occurs when loading the add-in, the LoadBehavior value changes to 2, and remains at 2 after the application closes. |
8 | Unloaded | Load on demand | The application does not try to load the add-in automatically. The user can try to manually load the add-in, or the add-in can be loaded programmatically. If the application successfully loads the add-in, the LoadBehavior value changes to 9. |
9 | Loaded | Load on demand | Set this value if you want your add-in to be loaded on demand. That is, the add-in will be loaded only when the application requires it, such as when a user clicks a UI element that uses functionality in the add-in (for example, a custom button in the Ribbon). If the application successfully loads the add-in, the LoadBehavior value remains 9, but the status of the add-in in the COM Add-ins dialog box is updated to indicate that the add-in is currently loaded. If an error occurs when loading the add-in, the LoadBehavior value changes to 8. |
16 | Loaded | Load first time, then load on demand | The application loads the add-in when the user runs the application for the first time. The next time the user runs the application, the application loads any UI elements that are defined by the add-in, but the add-in is not loaded until the user clicks a UI element that is associated with the add-in. When the application successfully loads the add-in for the first time, the LoadBehavior value remains 16 while the add-in is loaded. After the application closes, the LoadBehavior value changes to 9. |