Add a custom menu item in right-click menu (Context Menu) with Icons

Shmurda

New Member
Joined
Sep 5, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I have made a simple macro that adds a few macros to the context menu using the following template:

VBA Code:
Private Sub Workbook_Open()

Dim MyMenu As Object

Set MyMenu = Application.ShortcutMenus(xlWorksheetCell) _

    .MenuItems.AddMenu("This is my Custom Menu", 1)
    
With MyMenu.MenuItems

    .Add "MyMacro1", "MyMacro1", , 1, , ""

    .Add "MyMacro2", "MyMacro2", , 2, , ""

End With

Set MyMenu = Nothing

End Sub

It is very simple and works well, but unfortunately it doesn't seem possible to add icons (FaceIDs or custom) to either the "main" menu item or the sub-menus. So, my first question would be: Is this statement true? Is there no way to add icons using this method?

If it isn't possible, it seems like the only way to go forward would be to make use of CommandBar, since it is compatible with having icons. The thing is, I would like to be able to share this to my co-workers as an add-in, but every tutorial I find on the internet it seems like each individual would have to copy the code to their personal workbook, which is not optimal in my opinion. My second question would therefore be if any of you know if the CommandBar method is compatible with being used as an add-in?

There is a good post on StackOverflow about this (Add an icon to (custom right_click menu) , Application.ShortcutMenus), but I'm unsure how exactly this code is supposed to be run and how it would work with sharing with my colleagues. Are these methods also compatible with being used as an add-in? I'm specifically wondering about the "custom icons" one.

The best thing for me would of course be if there is a way to add icons (FaceIDs or custom, doesn't matter) to the current code I'm using. If this is impossible, hopefully someone can help me understand CommandBar a little better, and if it is compatible with .xlam add-ins. I appreciate all help :)
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
You cannot, as far as I know, add icons that way. Unless you are supporting very old versions of Excel, you would be better off (in my opinion) using the CustomUI editor to alter the built in shortcut menus. Even if you do use commandbars, there is no reason that the code cannot be in the add-in; it does not have to be in the user's personal macro workbook.
 
Upvote 1
Solution

Forum statistics

Threads
1,214,657
Messages
6,120,764
Members
448,991
Latest member
Hanakoro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top