Removing Paste from the right click menu

mattymc

New Member
Joined
Apr 27, 2011
Messages
3
In certain contexts I want to hide the paste option from the right click menu. In my proof of concept I was able to remove all but the paste option. It seems it is a weird group of controls, which doesn't want to be enabled or made not visible.

Here my attempt:

var allBars = ExcelApp.CommandBars;
for (int k = 1 ; k < allBars.Count; k++)
{
//var cellBar = ExcelApp.CommandBars["Cell"];
if (cellBar.Name == "Cell" || true)
{
for (int i = 1; i <= cellBar.Controls.Count; i++)
{
var control = cellBar.Controls;
if (control.Id == 3125 || control.Id == 3624 || control.Id == 21437 || control.Id == 22)
{
control.Enabled = false;
control.Visible = false;
}
}
}
}
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
That's not VBA code. What vesion of excel do you have and where are you running the code from ?
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

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