RibbonX OnLoad event crashes when Excel Workbook is 'Shared' and being opened in 'Normal' window (not Maximised)

Steve Stretch 1 Reputation point
2022-09-08T16:45:46.857+00:00

If a Shared Excel Workbook with a Custom Ribbon (RibbonX) has been previously saved while the window is in MAXIMISED and then opened again while the Excel Window is NORMAL (not Maximised) then you will get an error:

'Cannot run the macro 'xxxx_OnLoad'. The macro may not be available in this workbook or all macros may be disabled.

You can re-create a workbook by using this basic RibbonX code:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="rxcustomUI_onLoad">
<ribbon>
<tabs>
<tab id="tabCutol" label="TEST SHARED WB" >
<group id="gpData" label="Data" centerVertically="true">
<button id="btTest" label="Hello World" onAction="btTest_OnAction" imageMso="ImportMoreMenu" size= "large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

Followed by the VBA code in the workbook:

Public CutolDOCRibbon As IRibbonUI

Sub rxcustomUI_onLoad(ribbon As IRibbonUI)

Set CutolDOCRibbon = ribbon  

End Sub

Sub btTest_OnAction(ByRef control As IRibbonControl)
MsgBox "Houston, we have a problem!"
End Sub

Simply save the workbook and use the Share Workbook option and you'll be able to replicate.

Any advice or insight would be welcome.

Kind Regards

Steve

Microsoft 365 and Office | Development | Other
Developer technologies | Visual Basic for Applications
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Oskar Shon 866 Reputation points
    2022-11-11T12:54:19.34+00:00

    If you tape OnLoad in your XML then Check if you have procedure visible (not private)

    Sub OnLoad(ribbon As IRibbonUI)  
        Set gRibbon = ribbon  
    End Sub  
    

    in your case Sub rxcustomUI_onLoad

    This is a reference back from code.
    On x64 that blow up file from loading.

    Regards

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.