Microsoft Office 2000/Visual Basic Programmer's Guide   

Creating Menu Add-ins for Access

The simplest Access add-in is a menu add-in. A menu add-in calls a procedure in another database, perhaps a database that's serving as a code library. For example, a simple menu add-in might call a procedure that generates a report containing information about the various objects in the current database, such as the date they were created and their descriptions. Menu add-ins appear when you point to Add-ins on the Tools menu.

To create a menu add-in

  1. Add a subkey to the registry that specifies the name of the file containing the procedure and the name of the procedure itself. Menu add-ins are listed beneath the following subkey in the registry:

    \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Access\Addins\Menu Add-ins

  2. To specify the command that should appear on the Add-ins submenu of the Tools menu, create a new subkey beneath the add-in's subkey. For example, naming this subkey &Analyze Database Objects would result in a command named Analyze Database Objects on the Add-ins submenu.

  3. To hook up the menu command to the add-in, add two entries (in this case, String values) beneath the command's subkey, one named Expression and one named Library. Set the value of the Library entry to the path and file name of the database that contains the procedure that provides an entry point to the add-in. Set the value of the Expression entry to the name of the procedure itself. For example, if the procedure is named AnalyzeDatabaseObjects and it resides in a database named CodeLib.mda, you would set these entries as follows:

    Expression: "=AnalyzeDatabaseObjects()"

    Library: "C:\Windows\Application Data\Microsoft\AddIns\CodeLib.mda"

After you've added these keys, the new add-in command will appear on the Add-ins submenu of the Tools menu the next time you open Access.

Note   If you need to distribute your Access menu add-in to users, create an installable add-in as described in the next section, "Creating Installable Add-ins for Access," so that the add-in is properly registered on users' machines.