We help IT Professionals succeed at work.

Hoist the colors! We’ve added location flags to usernames sitewide, so it's easier to connect with the global community on EE. View My Profile

x

Excel ribbon customisation - contextmenus

1,338 Views
Last Modified: 2016-02-11
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 ?
Comment
Watch Question

Professor JMicrosoft Excel Expert
CERTIFIED EXPERT
Top Expert 2014

Commented:
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.

Author

Commented:
'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.
Rory ArchibaldGrand Poobah
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
As far as I am aware there is no equivalent to startFromScratch for contextmenus.

Author

Commented:
Anyone ?

Even the XML to disable all default context menu controls would help.

Author

Commented:
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'

Author

Commented:
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.
Professor JMicrosoft Excel Expert
CERTIFIED EXPERT
Top Expert 2014

Commented:
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

Author

Commented:
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.
Rory ArchibaldGrand Poobah
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
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.
Microsoft Excel Expert
CERTIFIED EXPERT
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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.
Professor JMicrosoft Excel Expert
CERTIFIED EXPERT
Top Expert 2014

Commented:
Thank you AL XReseach

Author

Commented:
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.
Professor JMicrosoft Excel Expert
CERTIFIED EXPERT
Top Expert 2014

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

Author

Commented:
ProfessorJimJam, thanks again, I am working on multiple developments so  please be patient between my replies. I am continuing to investigate this.

Author

Commented:
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

Author

Commented:
Anyone else can chip in of course ....

Author

Commented:
So far the only success I have found is :

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

Open in new window

Author

Commented:
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

Author

Commented:
Anyone else have any ideas ?
Martin LissSocial distance - Don't touch your face - Wash your hands for 20 seconds
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.