The Add-In Toolbar

While you can give users access to your add-in nearly anywhere in Visual Basic (this is covered in detail in Chapter 4), you might want to consider putting them on the Add-In toolbar.

The Add-In toolbar is provided with Visual Basic as a sort of "one-stop shopping" for all of your add-ins and Wizards. It's a site where you can place your add-ins and Wizards as buttons for easy access. Also, the add-in or Wizard is not loaded until a user clicks the button. It saves the user from the task of going into the Add-In Manager, clicking the box of an add-in that they want, then clicking OK. If you place your add-in on the Add-In toolbar, it appears as a button. To invoke and load the add-in, simply click its button. Very convenient!

Note   You can place Wizards on the Add-In Toolbar as well as add-ins.

To start the Add-In toolbar, choose "VB Add-In Toolbar" in the Add-In Manager. You should see a small toolbar appear beneath the Standard toolbar:

The first button on the left (the "+/-" button) allows you to add or remove items from the toolbar. To add it, browse for your add-in, check its box in the Available Add-Ins list, then click OK. Your add-in (or Wizard) should appear on the Add-In toolbar. For more information on the Add-In toolbar dialog box, search the Visual Basic documentation.

Of course, you're also given programmatic control of the Add-In toolbar, since it's probably impractical to visit the computer of every person you give your add-in to make sure it's showing on their Add-In toolbar.

The Add-In toolbar object model has an object known as the Manager object. It contains two methods:

These methods allow you to programmatically place and remove buttons to and from the Add-In toolbar.

This code is an example of how to programmatically add an add-in to the Add-In toolbar and ensure that the Add-In toolbar is automatically loaded the next time Visual Basic is started:

Sub Main()
   dim x as Object
   Set x=CreateObject("AddInToolbar.Manager")
      x.AddToAddInToolbar ("C:\VB\MyAdd.DLL", _  
      "MyAddIn.Connect", "MyAddIn Title", True, True)
End Sub

This code is an example of how to remove an add-ins button from the Add-In toolbar:

Sub Main()
   dim x as Object
   Set x=CreateObject("AddInToolbar.Manager")
   x.RemoveAddInFromToolbar sAddInName:="MyAddIn Title"
End Sub

The registry location for the Add-In toolbar is (HKEY_CURRENT_USER\Software\Microsoft\VBA\Microsoft Visual Basic\AddInToolbar).