Cell shortcut menu no longer works in Excel 365

spidaman

Board Regular
Joined
Jul 26, 2015
Messages
114
Office Version
  1. 365
Platform
  1. Windows
Can anyone using Excel 365 please help me identify the problem with a cell shortcut menu added as a workbook open routine?

In Excel 2013 the below code previously created a shortcut right-click menu from any cell. However since migrating to Excel 365 it no longer functions. I have tried various fixes and searched high and low for an answer but unsure why the code no longer works. The procedure is placed in the ThisWorkbook module.


VBA Code:
Private Sub Workbook_Open()

Shortcuts

End Sub


Public Sub Shortcuts()

Dim MyMenu As Object

    Set MyMenu = Application.ShortcutMenus(xlWorksheetCell).MenuItems.AddMenu("Countries", 1)

        With MyMenu.MenuItems
            .Add "CAN", "CAN_cut", , 1, , ""
            .Add "ESP", "ESP_cut", , 2, , ""
            .Add "FRA", "FRA_cut", , 3, , ""
            .Add "GBR", "GBR_cut", , 4, , ""
            .Add "USA", "US_cut", , 5, , ""
        End With

    Set MyMenu = Nothing

End Sub

Thanks in advance for any suggestions.
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,983
Office Version
  1. 365
Platform
  1. Windows
Macro blocked by security settings?

I just tried your code with 365 and it works fine.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,311
Office Version
  1. 365
Platform
  1. Windows
Try adding a message box to see if the code runs
VBA Code:
Private Sub Workbook_Open()
MsgBox "ok"
Shortcuts

End Sub
 

spidaman

Board Regular
Joined
Jul 26, 2015
Messages
114
Office Version
  1. 365
Platform
  1. Windows
Macro blocked by security settings?

I just tried your code with 365 and it works fine.
It can't be as I have all macros enabled in settings - see attached
 

Attachments

  • Settings.PNG
    Settings.PNG
    11.5 KB · Views: 1

spidaman

Board Regular
Joined
Jul 26, 2015
Messages
114
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Try adding a message box to see if the code runs
VBA Code:
Private Sub Workbook_Open()
MsgBox "ok"
Shortcuts

End Sub
Hi Fluff - I tried this and the msgbox does run successfully on start-up.....so seems ok
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,311
Office Version
  1. 365
Platform
  1. Windows
In that case it should work.
If I run your code I get the Countries as the 1st item in the right click menu, unless I try it in a structured table.
 

spidaman

Board Regular
Joined
Jul 26, 2015
Messages
114
Office Version
  1. 365
Platform
  1. Windows
In that case it should work.
If I run your code I get the Countries as the 1st item in the right click menu, unless I try it in a structured table.
Yes that's how it presented in 2013 version for me. It's a strange one. I couldn't see any reason why it shouldn't run. Please let me know if you have any other thoughts. There are some other open workbook procedures that might be causing complications but nothing that wasn't already added in the 2013 version. I'll try experimenting more anyway.

Thanks for your help.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,983
Office Version
  1. 365
Platform
  1. Windows
Try using a Stop command instead of the message box that Fluff suggested, then use f8 to step through the code and see if it appears then.

It didn't work for me first attempt so I tried the above and it worked fine, although I think that the initial fail was due to me right clicking in a table which is why I didn't mention in previously.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,346
Messages
5,601,079
Members
414,426
Latest member
fraru

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
Top