Excel VBA Context Menu

1.4k Views Asked by At

Problem: When you try to change ContextMenu("Cell") (Right Click in a cell) sometimes you can see how the context menu changed, and sometimes you don't.

You ever wonder why? I'll share it so I can save some other newbie's time.

For an example Ron de bruin 'How to build & change ContextMenu'

1

There are 1 best solutions below

0
On

Reason: Excel has different ContextMenu with the same name (in this case Cell) that are only shown in specific situations. For instance, depending on the current layout mode (Page Break Preview or Normal) it will call different Menu.

Solution: Credit goes to MrExcel.

Set different commandbar control as:

Dim ContextMenu    as Commandbar
Dim ContextMenuPBP as CommandBar

Set ContextMenu = Application.CommandBars("Cell")
Set ContextMenuPBP = Application.CommandBars.FindControl(ID:=1588).Parent

Now you only need to change both menus and you will be able to see the changes no matter in which mode the user is working on.