Reputation: 9538
I am trying to learn something new. I have created a custom tab based on Siddharth Rout' tutorial. The XML part is like that
<customUI onLoad="RibbonOnLoad" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="MyCustomTab" label="MyTab" insertAfterMso="TabView">
<group id="customGroup1" label="First Tab">
<button id="customButton1" label="JG Button 1" imageMso="HappyFace" size="large" onAction="Callback1" />
<button id="customButton2" label="JG Button 2" imageMso="PictureBrightnessGallery" size="large" onAction="Callback2" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Then in workbook module I put this code so as to activate the tab when the workbook is open
Private myRibbon As IRibbonUI
Sub OnLoad(ribbon As IRibbonUI)
Set myRibbon = ribbon
myRibbon.ActivateTabMso ("MyTab")
End Sub
But when I opened the workbook, I encountered an error Can't run the macro RibbonOnLoad
. I am using Office 365 32 Bit and Windows 10 64 Bit.
Upvotes: 1
Views: 369
Reputation: 8104
First, as freeflow has already mentioned, the callback should be RibbonOnLoad
. Secondly, you should be using the ActivateTab method, since it's a custom tab. And thirdly, you should be specifying the control ID, not the tab name. Try the following code, which needs to be placed in a regular module...
Private myRibbon As IRibbonUI
'Callback for customUI.onLoad
Sub RibbonOnLoad(ribbon As IRibbonUI)
Set myRibbon = ribbon
myRibbon.ActivateTab "MyCustomTab"
End Sub
Upvotes: 2