Hiding Build-In Control In Context Menu and Replace It

Add-in Express™ Support Service
That's what is more important than anything else

Hiding Build-In Control In Context Menu and Replace It
 
ideaFocus




Posts: 63
Joined: 2013-07-19
Hi,

I want to hide the Insert... in the context menu and replace it with my control. I figured it would be same as hiding the groups in tab so I followed this article: http://www.add-in-express.com/creating-addins-blog/2012/05/29/write-addins-excel2010/

1. We need our control right before Delete so I changed the InsertBeforeIdMso to &Delete...

2. For hiding the Butil-in Insert from the Context Menu I created the another button and gave it &Insert... as IdMso and sets it's Visible property to false.

Am I missing something here.

Thanks,
Attiqe

P.S: You can download the sample project from here: http://1drv.ms/1oKppJu
Posted 22 Mar, 2014 09:34:14 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Attiqe,

#2. Instead of this you need to hide the CommandBarControl having Id=3181 in the CommandBar-based context menus (CommandBar.Type=Office.MsoBarType.msoBarTypePopup) having CommandBar.Name = "Cell", "Column" and "Row". Note that this change requires that you restore the visibility of that control. I suggest doing this in the AddinBeginShutdown event.


Andrei Smolin
Add-in Express Team Leader
Posted 24 Mar, 2014 03:34:19 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Anderi,

It would be really helpful if you can send me a sample project that will help me understand it better.

Thanks,
Attiqe
Posted 25 Mar, 2014 10:01:47 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Attiqe,

My name is Andrei )))

Here's a citation from the manual:

It is easy to navigate down the command bar system: the host application supplies you with the Office.CommandBars interface that provides the Controls property returning a collection of the Office.CommandBarControls type. Office.CommandBarPopup provides the Controls property, too.


That is, you scan the CommandBars collection for context menus having CommandBar.Name = "Cell", "Column" and "Row". A context menu is a CommandBar having CommandBar.Type=Office.MsoBarType.msoBarTypePopup. Then you scan the CommandBar.Controls collection looking for a CommandBarControl having a required CommandBarControl.Id (see above). Finally, you set CommandBarControl.Visible=myValue.


Andrei Smolin
Add-in Express Team Leader
Posted 25 Mar, 2014 10:13:41 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Andrei,

My bad :), please accept my sincerest apologies. I am able to hide Insert & Delete button but I am unable to show ADXRibbonMenu at their place.

I used InsertAfterId=3125 or InsertAfterIdMso=Clear Con&ntents but the ADXRibbonMenu doesn't show at all in ContextMenu.


-A
Posted 25 Mar, 2014 14:01:59 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Attiqe,

ideaFocus writes:
I used InsertAfterId=3125 or InsertAfterIdMso=Clear Con&ntents but the ADXRibbonMenu doesn't show at all in ContextMenu.


These properties accept Ribbon-related information while both 3125 and "Clear Con&ntents" are taken from the commandBar system. Download the files mentioned in the manual - see the section Referring to Built-in Ribbon Controls - open the ExcelControls workbook and find the IdMso of that control. For me this is "ClearContents". I've tried positioning a Ribbon control by specify InsertBeforeIdMso="ClearContents" but this doesn't work.

At the moment I assume this isn't possible to achieve using Ribbon components. When I have time, I'll look into this once again.

The workaround is to position the commandbarControl say by specifying BeforeId=3125. That is, you add three ADXContextMenu components, set their SupportedApp properties to "Excel" and specify their CommandbarName properties as follows: "Cell", "Column", "Row". Add a button to each of the context menu components and position the buttons using BeforeId or AfterId property. Since this is a Commandbar-related context menu, the Id must be taken from the commandbar system. You can find all such IDs using our free Built-in Controls Scanner, see http://www.add-in-express.com/downloads/mapi-store-events.php.


Andrei Smolin
Add-in Express Team Leader
Posted 26 Mar, 2014 04:26:48 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Andrei,

I have perform the following steps:

1. For "Cell", "Column", "Row" - http://1drv.ms/1p9RcTM
2. I used InsertBeforeIdMso - http://1drv.ms/1p9RN85
3. My ADXRibbonMenu appear right - http://1drv.ms/1p9S4bb

Please check project-http://1drv.ms/1eSJWIF- which is working with Copy and Cut but not with Clear Contents.

-A
Posted 27 Mar, 2014 00:55:19 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Great!

So, positioning works in the ribbon context menu! Great!

InsertBeforeIdMso="ClearContents" doesn't work for me as well. But InsertAfterIdMso="Delete" produces the required result.

Note that I get an exception in AddinModule_AddinBeginShutdown while testing the project. I suggest that you modify that code to prevent the exception.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Mar, 2014 07:08:11 Top
ideaFocus




Posts: 63
Joined: 2013-07-19
Andrei,

With Delete it isn't working for me. I tried it on with InsertAfterIdMso="Delete" and InsertBeforeIdMso="Delete".

-A
Posted 27 Mar, 2014 11:18:26 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
I'm terribly sorry. Please use InsertAfterIdMso="CellsDelete".


Andrei Smolin
Add-in Express Team Leader
Posted 28 Mar, 2014 04:25:37 Top