Link to home
Start Free TrialLog in
Avatar of AL_XResearch
AL_XResearchFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel ribbon customisation - contextmenus

I have created an Excel addin (XLAM file) which has completely custom ribbons (i.e. I have used 'StartFromScratch in the XML).

I now wish to add some items to the cell context menu. I know how to do this (via the '<ContextMenus> element and children) but the problem is that I don't want to leave any of the standard commands on the context menu - except those that I add.

Is there a quick way to hide all the in-built menu items (like a 'StartFromScratch' for the <ContextMenus> block) ?

I know if course that I can hijack the default menu items via 'idMSO' and then set the visibility to false but I want to avoid the time it takes to do this for every item.

Can anyone help ?
Avatar of Professor J
Professor J

i am not sure if i understood your question correctly.  but to remove all built in meny from cell or from any other then you might wanna try the free Add-IN  MenuRighter  http://yoursumbuddy.com/menurighter/
  then from the drop down in the right select Cell and then from the right icons select remove and you can remove all of them except one last one.   and in case if you wanted to restore to default, then you just simple click reset to default.
Avatar of AL_XResearch

ASKER

'ProfessorJimJam' thanks for the quick response.

To clarify; I want to know if there is a quick way to remove / hide all items in the cell context menu using only RibbonX XML

I will keep that tool in my box of resources, thanks. Unfortunately on this project third party addins are not an option.

I have coded a completely unique ribbon for this addin that replaces all Excel tabs and groups.

I just want to know how do to clear the context menu quickly in RibbonX - other than the methods I have already covered.
As far as I am aware there is no equivalent to startFromScratch for contextmenus.
Anyone ?

Even the XML to disable all default context menu controls would help.
Any suggestions or control names would be appreciated because I have the complete list of Excel controls (from MS in an Excel workbook) and I can't find any controls for 'ContextMenuCell'
Of course I realise that I could use the Commandbars object to hide the existing controls but a) I don't know how long MS are going to keep Commandbars in VBA and b) I would rather not crate a Ribbon X + Commandbars mixed solution.

Someone out there must have some knowledge on how to either clear the context menu, the control names for all it's items so they can be made invisible or some other method.

I really need a solution here. No third party addons or anything that requires installation can be used.
this example can get you started.  with customUI editor, using the example below, you have to do it it per menu.


<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <contextMenus>
        <contextMenu idMso="ContextMenuCell">
            <gallery idMso="PasteGalleryMini" visible="false"/>
        </contextMenu>
    </contextMenus>
</customUI>

Open in new window

ProfessorJimJam: thank you for the quick response.

I already have this code and have successfully added my own custom button to the cell context menu but I need to hide (i.e. 'visible=false') all the built in Excel commands on the 'ContextMenuCell' menu

Unfortunately the MS download, that supposedly lists all the ribbonX controls for Excel 2010' does not include any child controls for 'ContextMenuCell' - hence my appeal for other Excel experts to come to the rescue.
See the bottom of this article: https://msdn.microsoft.com/en-us/library/gg469862.aspx#odc_xl_ta_CustomExcelContextMenus_ContextMenuTipsTricks

Essentially, there is no list available, so you need to use code to hide them.
ASKER CERTIFIED SOLUTION
Avatar of Professor J
Professor J

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ProfessorJimJam, thank you so much. That is exactly what I was looking for

I am trying your example XML and it does remove 80% of the cell context menu items.

I have used Andy Pope's ribbon editor before but for the life of me could not remember what it was called and so was unable to search online directly.

As I say I am looking to nail down the last few context menu items and when I do I will update this question so no one else has to go the tedious trial and error route.
Thank you AL XReseach
ProfessorJimJam:

in addition, you may also use Andy pope's RibbonX visual designer where you do not need to write any code, simply add commands

Unless I am missing something Andy's excellent little tool does not allow you to create / edit context menus. Please tell me I am wrong.
You can but you need to look for it on Andy's guide page on how to do it.
ProfessorJimJam, thanks again, I am working on multiple developments so  please be patient between my replies. I am continuing to investigate this.
ProfessorJimJam, can you direct me to the correct page on Andy Pope's website, you previously mentioned, that covers the cell context menu. I have searched his site and can find nothing that mentions it

You can but you need to look for it on Andy's guide page on how to do it.

Thanks.

Even using your excellent XML example for the cell context menu, I am still left with the following commands on the right-click. I am using trial-and-error to try and find the correct MsoID to control them but have so far failed.

Paste Speical
Insert ...
Clear contents
Filter (menu)
Sort (menu)
Insert Comment
Pick from Drop Down List
Hyperlink
Anyone else can chip in of course ....
So far the only success I have found is :

<button idMso="HyperlinkInsert" visible="false" />

Open in new window

I can find no documentation or article online that details the XML code for the outstanding context menu items.

For the moment I just have to accept that there is no way to remove these items using only RibbonX
Anyone else have any ideas ?
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.