- Here is an example of rough code with comments
- It was created in VS2010 and tested against Excel 2010.
- The first step was to create a new Excel 2010 Add-In project.
- Then the sample code is added below the code created inside ThisAddin.cs .
- This code will add a new menu item and delete the cut / copy / paste menu items when you right-click on one cell containing "abc". This should simulate changing the context menu based on the contents of the cell.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Excel = Microsoft.Office.Interop.Excel; using Office = Microsoft.Office.Core; using Microsoft.Office.Tools.Excel; using System.Diagnostics; using Microsoft.Office.Interop.Excel; namespace Excel_Menu { public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { ResetCellMenu();
Peter Trenery
source share