Ribbon MenuHandler

41 views
Skip to first unread message

Roland Kapl

unread,
Aug 17, 2023, 1:29:56 PM8/17/23
to Excel-DNA
Dear Govert!

Today I made a strange observation. When debugging my Add-In and suspecting the Ribbon/MenuHandler, I decided to disable the MenuHandler by uncommenting the assignment to the instance variable, assuming that no Ribbon would be appearing:

Public Sub AutoOpen() Implements IExcelAddIn.AutoOpen
        ' necessary for ExplicitRegistration of param arrays (https://groups.google.com/forum/#!topic/exceldna/kf76nqAqDUo)
        ExcelRegistration.GetExcelFunctions().ProcessParamsRegistrations().RegisterFunctions()
        ExcelRegistration.GetExcelCommands().RegisterCommands()
        Application = ExcelDnaUtil.Application

        ' Ribbon and context menu setup
        'theMenuHandler = New MenuHandler
...

Now to my surprise, the menu still was there and worked completely. Now I'm wondering, whether this was changed to some "singleton" implementation or what's the reason for this working like that?

My MenuHandler looks pretty normal:
<ComVisible(True)>
Public Class MenuHandler
    Inherits CustomUI.ExcelRibbon

    Public Sub ribbonLoaded(theRibbon As CustomUI.IRibbonUI)
        MenuHandlerGlobals.theRibbon = theRibbon
    End Sub

    Public Overrides Function GetCustomUI(RibbonID As String) As String
....


-regards,
Roland

Govert van Drimmelen

unread,
Aug 18, 2023, 4:21:36 PM8/18/23
to Excel-DNA
Hi Roland,

When loading, Excel-DNA checks for classes that derive from ExcelRibbon and loads these (as COM add-ins) automatically.
So you don't have to load these explicitly.

-Govert

Roland Kapl

unread,
Aug 21, 2023, 10:36:46 AM8/21/23
to Excel-DNA
Ok, then I did it wrong all the time up to now!
Thank you!
Roland 

Reply all
Reply to author
Forward
0 new messages