• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

7. Macro Hacks > 62. Keep Custom Menus Under Control

Keep Custom Menus Under Control

This hack reveals how to make sure macros that create custom menu items clean up after themselves.

This hack shows you how to automatically add a menu item for the RevertToSaved macro [Hack #5] in a global template named MacrosTemplate.dot. It adds the menu item underneath the Save As command on the File menu. The hack also shows how to use VBA to remove the menu item.

The Code

The code uses two procedures: AddMenuItem and RemoveMenuItem. The AddMenuItem macro first calls the RemoveMenuItem procedure to delete the custom menu item if it already exists. It then creates a new menu item just below the Save As command on the File menu. If, for some reason, the macro can’t find the Save As command on the File menu, it places the custom item at the bottom of the menu.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint