I've been using this to modify the context menu (right-click) in Excel.
The method below is when in Page Break preview, which is different to Normal View. "+3" is the difference, at least for Office 365.
Not sure if Sort was available initially, as I may have deleted before.
Trying to reinstate Sort with the last line/s of code but not working.
The method below is when in Page Break preview, which is different to Normal View. "+3" is the difference, at least for Office 365.
Not sure if Sort was available initially, as I may have deleted before.
Trying to reinstate Sort with the last line/s of code but not working.
VBA Code:
Sub add_del_context_menu()
Dim context_menu As CommandBar
'Page Break Preview
'------------------
Application.CommandBars(Application.CommandBars("Cell").Index + 3).Reset
Set context_menu = Application.CommandBars(Application.CommandBars("Cell").Index + 3)
On Error Resume Next
'varies for each Excel version
context_menu.FindControl(ID:=25536).Delete 'Smart Lookup
context_menu.FindControl(ID:=3181).Delete 'Insert...
context_menu.FindControl(ID:=292).Delete 'Delete...
context_menu.FindControl(ID:=3125).Delete 'Clear Contents
context_menu.FindControl(ID:=24508).Delete 'Quick Analysis
context_menu.FindControl(ID:=31402).Delete 'Filter
context_menu.FindControl(ID:=34003).Delete 'Get Data from Table/Range
context_menu.FindControl(ID:=1966).Delete 'Pick From Drop-down List
context_menu.FindControl(ID:=13380).Delete 'Define Name
Application.CommandBars.FindControl(ID:=31435).Enabled = True 'Try 1
Application.CommandBars.FindControl(ID:=31435 + 3).Enabled = True 'Try 2
End Sub