0

My team created Excel Add-in toolbars to open our Excel macro tools. The custom functions in these Add-in are no longer displaying (or accessible) on the Excel 'right-click' menu.

We use Windows 10 / 64-bit MS Office 365/2016.

Were these UDFs disabled by Microsoft?
I have no way to know if these are disabled by the security of our company.

Public Sub AddItemToCellMenu()
'Application.CommandBars("Cell").Reset
Dim cmdBar As CommandBar, cmdPopup As CommandBarPopup, cmdButton As CommandBarButton

On Error GoTo ErrorHandler:

Set cmdBar = Application.CommandBars("Cell") '35
Set cmdPopup = cmdBar.Controls.Add(Type:=msoControlPopup, Before:=1)

With cmdPopup
   .Caption = "My Popup"
End With

Set cmdButton = cmdPopup.Controls.Add(Type:=msoControlButton)
With cmdButton
   .Caption = "This is my macro1"
   .OnAction = "Mymacro1"
   .FaceId = 370
End With

Set cmdButton = cmdPopup.Controls.Add(Type:=msoControlButton, Before:=1)
With cmdButton
   .Caption = "This is my macro2"
   .OnAction = "Mymacro2"
   .FaceId = 370
End With

Exit Sub

ErrorHandler:
Debug.Print Err.Number & " " & Err.Description

End Sub

Public Sub Mymacro1()
MsgBox "My macro 1"
End Sub

Public Sub Mymacro2()
MsgBox "My macro 2"
End Sub
3
  • 1
    There are two Cell menus in Excel - which one you see depends on which page view you are in - Normal or Page Layout/Page break preview. Perhaps you are in one of the latter views?
    – Rory
    Commented Feb 12, 2024 at 15:25
  • The code works just fine for me
    – jkpieterse
    Commented Feb 12, 2024 at 15:46
  • Hi Rory. I was in Normal view, but I also tried the others and same result. jkpieterse - Are you stating you created an Excel Add-in and when you sect a range of cells, you see these on the right-click menu? If so, our company may have disabled this feature.
    – VBA_Guy
    Commented Feb 12, 2024 at 16:59

1 Answer 1

0
  • Your code changes the content menu for Normal and Page Layout. But it doesn't change the menu on Page Break Preview.

  • Both content menu name are Cell.

  • Tested on M365

enter image description here

Please try.

Public Sub AddItemToCellMenu()
    Dim cmdBar As CommandBar, cmdPopup As CommandBarPopup, cmdButton As CommandBarButton
    On Error GoTo ErrorHandler:
    For Each cmdBar In Application.CommandBars
        If cmdBar.Name = "Cell" Then
            cmdBar.Reset
            Set cmdPopup = cmdBar.Controls.Add(Type:=msoControlPopup, Before:=1)
            With cmdPopup
                .Caption = "My Popup"
            End With
            Set cmdButton = cmdPopup.Controls.Add(Type:=msoControlButton)
            With cmdButton
                .Caption = "This is my macro1"
                .OnAction = "Mymacro1"
                .FaceId = 370
            End With
            Set cmdButton = cmdPopup.Controls.Add(Type:=msoControlButton, Before:=1)
            With cmdButton
                .Caption = "This is my macro2"
                .OnAction = "Mymacro2"
                .FaceId = 370
            End With
        End If
    Next
    Exit Sub
ErrorHandler:
    Debug.Print Err.Number & " " & Err.Description
End Sub
3
  • Thank you taller. This does work in Page Break Preview, but not Normal or Page Layout. What do I need to do to get it to work in Normal view?
    – VBA_Guy
    Commented Feb 12, 2024 at 18:11
  • I've tested on M365. It works well in all view modes. What's your Excel version?
    – taller
    Commented Feb 12, 2024 at 18:33
  • I am using 64-bit MS Excel 2016 (Version 2308 Build 16.0.16731.20496).
    – VBA_Guy
    Commented Feb 13, 2024 at 13:50

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.