Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

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

Chapter 23: Working with Shortcut Menus > Using VBA to Customize Shortcut Menus

Using VBA to Customize Shortcut Menus

In this section, I present some practical examples of VBA code that manipulates Excel's shortcut menus. These examples give you an idea of the types of things you can do with shortcut menus, and they can all be modified to suit your needs.

Resetting a shortcut menu

The Reset method restores a shortcut menu to its original, default condition. The following procedure resets the Cell shortcut menu to its normal state:

Sub ResetCellMenu()

CommandBars(“Cell”).Reset

End Sub

As I noted earlier, Excel has two shortcut menus named Cell. The preceding code resets only the first one (index of 35). To reset the second Cell shortcut menu, you can use its index number (38) instead of its name. But remember, the index numbers aren't consistent across Excel versions. Here's a better procedure to reset both instances of the Cell shortcut menu:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint