Showing Popup Command Bars

If you want to display a shortcut menu without having to right-click a cell, or chart, you can create code to display the shortcut in a number of ways. For example, you might like to display the shortcut Cell command bar from the keyboard, using Ctrl+Shift+C. You can do this using the following code:

Sub SetShortCut()

Application.OnKey "A+c", "ShowCellShortCut" End Sub

Private Sub ShowCellShortCut()

CommandBars("Cell").ShowPopup x:=0, y:=0 End Sub

ShowCellShortCut uses the ShowPopup method to display the Cell shortcut menu at the top-left corner of the screen. The parameters are the x and y screen coordinates for the top-left corner of the menu.

You can also create a popup menu from scratch. The popup in Figure 15-13 appears when you right-click inside the range named Database. Outside the range, the normal Cell popup menu appears.

1 Name Ags Sex

2 Bill 3G M

3 ¬°Francine 23 F

1 Name Ags Sex

2 Bill 3G M

3 ¬°Francine 23 F

ll Sort Ascending It Sort Decendiug

13 ! Sally

14 Sheila

15 Simon _16_: Terry

17 Wacka

18 Warren

ll Sort Ascending It Sort Decendiug

13 ! Sally

14 Sheila

15 Simon _16_: Terry

17 Wacka

18 Warren

Figure 15-13

0 0

Post a comment