ideaFocus
Posts: 63
Joined: 2013-07-19
|
Hi,
I am trying to intercept Paste and for that I used ADXBuiltInControl and ADXRibbonCommand(I have used Paste and PasteTextOnly). Here's the code:
this.adxBICCopy.CommandBar = null;
this.adxBICCopy.ControlTag = "a2da64cc-cd1c-487c-9e64-8742dd72dd90";
this.adxBICCopy.Id = 19;
this.adxBICCopy.ActionEx += new AddinExpress.MSO.ADXActionEx_EventHandler(this.adxBICCopy_ActionEx);
//
// adxBICPaste
//
this.adxBICPaste.CommandBar = null;
this.adxBICPaste.ControlTag = "93d2d540-8037-4a93-90be-3e0021700bb1";
this.adxBICPaste.Id = 22;
this.adxBICPaste.ActionEx += new AddinExpress.MSO.ADXActionEx_EventHandler(this.adxBICPaste_ActionEx);
//
// adxRCPaste
//
this.adxRCPaste.Id = "adxRibbonCommand_34435a488e60434383f75e3e4fbb03b8";
this.adxRCPaste.IdMso = "PasteTextOnly";
this.adxRCPaste.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;
this.adxRCPaste.OnAction += new AddinExpress.MSO.ADXRibbonCommand_EventHandler(this.adxRCPaste_OnAction);
Although Copy is working with both of them.
Thanks,
Attiqe |
|
Andrei Smolin
Add-in Express team
Posts: 18822
Joined: 2006-05-11
|
Hello Attiqe,
In Excel 2010-2013, they allow you to choose a paste operation from a gallery (IdMso="PasteGalleryMini") which is shown in the context menu. Another gallery (IdMso="PasteGallery") is shown when you hover the Paste Special button in the context menu. Choosing an option from these galleries doesn't trigger a Ribbon Command.
You have two ways:
- disable these galleries: put an ADXRibbonCommand onto the add-in module, set the command's ActionTarget property to NonActionControl (this disables the event handler of the OnAction event) and Enabled=False;
- undo the paste action (see below)
private void adxExcelEvents_SheetChange(object sender, object sheet, object range) {
Office.CommandBars cmdBars = ExcelApp.CommandBars;
Office.CommandBarComboBox cbxUndo = cmdBars.FindControl(Type.Missing, 128) as Office.CommandBarComboBox;
if (cbxUndo != null) {
if (cbxUndo.Enabled && cbxUndo.ListCount > 0) {
string undoText = cbxUndo.List[1];
System.Diagnostics.Debug.WriteLine("!!! adxExcelEvents_SheetChange. undoText=" + undoText);
if (undoText == "Paste Special")
cbxUndo.Execute();
}
Marshal.ReleaseComObject(cbxUndo); cbxUndo = null;
}
Marshal.ReleaseComObject(cmdBars); cmdBars = null;
}
Andrei Smolin
Add-in Express Team Leader |
|