Add a custom command that runs a Visual Basic function to a menu

  1. Create the function you want the command to run.

    How?

  2. On the View menu, point to Toolbars, and then click Customize.

  3. If it isn't already displayed, show the menu bar, shortcut menu, or toolbar containing the menu that you want to add the command to.

    How?

  4. In the Customize dialog box, click the Commands tab.

  5. In the Categories box, click File.

  6. Drag the Custom command from the Commands box over the menu on the menu bar or the toolbar, or under the appropriate category on the Shortcut Menus toolbar. When the menu displays a list of menu commands (or an empty box if it's new), point to the location where you want the command to appear on the menu, and then release the mouse.

  7. With the Customize dialog box open, right-click the command on the menu, and then on the shortcut menu, type a new name for the command in the Name box.

  8. On the same shortcut menu, click Properties.

  9. In the On Action box, type the name of the function you want to run in the format =functionname(). For example, for a custom function named SetCaption(), type =SetCaption(). For a built-in function, enter the name of the function and any required arguments, for example =MsgBox(IIf(Instr(Time(), "PM"), "Good Afternoon", "Good Morning")).

  10. Specify any other properties for the command.

Note   If you add a command to a built-in menu (for example, the Edit menu), that command appears in all views having that built-in menu.