BrianExcel
Well-known Member
- Joined
- Apr 21, 2010
- Messages
- 975
I am using the following code to populate a custom context menu in my workbook:
I went ahead and integrated the "Delete from Cell Menu" code into the same module just to make it a bit easier.
My problem is that in addition to the menu I want, which is appearing correctly, currently as the fourth option down, the context menu is also giving me 3 additional blank options before it. Each one is similar to a drop-down, and has no code attached to it, but I can't figure out how to remove them.
See the attached picture for the menus I am referring to...
Anyone have any ideas how I can remove those three menus?
Code:
Sub AddToCellMenu()Dim ContextMenu As CommandBar
Dim MySubMenu As CommandBarControl, ctrl As CommandBarControl
'Set ContextMenu to the Cell menu
Set ContextMenu = Application.CommandBars("Cell")
For Each ctrl In ContextMenu.Controls
If ctrl.Tag = "My_Cell_Control_Tag" Then
ctrl.Delete
End If
Next ctrl
'Set ContextMenu to the Cell menu
Set ContextMenu = Application.CommandBars("Cell")
'Add custom menu with two sub-buttons
Set MySubMenu = ContextMenu.Controls.Add(Type:=msoControlPopup, before:=4)
With MySubMenu
.Caption = "Raw Data Access"
.Tag = "My_Cell_Control_Tag"
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Hide_Unhide_Venue_Info"
.FaceId = 4165
.Caption = "Hide / Unhide Venue Info"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Hide_Unhide_Expense_Account_Guide"
.FaceId = 4165
.Caption = "Hide / Unhide Expense Account Guide"
End With
End With
End Sub
I went ahead and integrated the "Delete from Cell Menu" code into the same module just to make it a bit easier.
My problem is that in addition to the menu I want, which is appearing correctly, currently as the fourth option down, the context menu is also giving me 3 additional blank options before it. Each one is similar to a drop-down, and has no code attached to it, but I can't figure out how to remove them.
See the attached picture for the menus I am referring to...
Anyone have any ideas how I can remove those three menus?
Last edited: