VBA code required to delete Right click menu over SHAPES

mchilapur

Board Regular
Joined
Apr 14, 2014
Messages
126
Dear all,

I am using below code to delete the RIGHT CLICK menu items when clicked over any cell.
How best i can modify this code to delete the RIGHT CLICK menu items when clicked over any SHAPES (Say an Image or rectangle) as well...?


Sub RMenus_Remove()


Dim myCommandBar As Office.CommandBar
Dim ctrl As Office.CommandBarControl
Dim i As Integer, j As Integer
Dim a(20) As String

'//A list of right click menu items I don't need to see
a(0) = "Pic&k From Drop-down List..."
a(1) = "Add &Watch"
a(2) = "&Create List..."
a(3) = "&Hyperlink..."
a(4) = "&Look Up..."
a(5) = "Cu&t"
a(6) = "Clear Co&ntents"
a(7) = "&Format Cells..."
a(8) = "&Paste"
a(9) = "Paste &Special..."
a(10) = "Name a &Range..."
a(11) = "&Insert..."
a(12) = "&Delete..."


'//Tag the above list of inbuilt controls with my tag -
' my remove procedure will then remove them just like my custom controls
For Each myCommandBar In Application.CommandBars
If myCommandBar.Name = "Cell" Then
For Each ctrl In myCommandBar.Controls
For j = 0 To UBound(a)
If ctrl.Caption = a(j) Then


ctrl.Delete
Exit For
End If
Next j
Next ctrl
End If
Next myCommandBar




End Sub

Any urgent response will be of great help.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If you protect the worksheet then right-clicking the shape doesn't bring up the context menu
 
Upvote 0
Unfortunately this is not true for the worksheet Textbox - which is a shape object. Disabling the shapes menu does not disable shape textbox right-click menus. And even if a worksheet is protected, Excel will still show a right-click menu on a worksheet textbox, which allows the user to edit the textbox. I think this is a bug (or design failure) in Excel worksheet protection. If I put a worksheet textbox on a protected sheet to provide instructions to the user, why in the world would I want any user to be able to edit the Textbox on a protected worksheet?

If you protect the worksheet then right-clicking the shape doesn't bring up the context menu
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,639
Members
449,093
Latest member
Ahmad123098

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top