问题
I have an Excel 2013 workbook and am trying to switch a custom tab when the it is opened.
I have the following CustomUIx.xml entries:
CustomUI.xml
<customUI onLoad="RibbonOnLoad" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="CustomHFG" label="Custom" insertAfterMso="TabDeveloper">
</tab>
</tabs>
</ribbon>
CustomUI14.xml
<customUI onLoad="RibbonOnLoad" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="CustomHFG" label="Custom" insertAfterMso="TabDeveloper">
</tab>
</tabs>
</ribbon>
and the folloing VBA code in a module:
Option Explicit
Public ribRibbon As IRibbonUI
Public Sub RibbonOnLoad(ribbon As IRibbonUI)
Set ribRibbon = ribbon
ribRibbon.ActivateTab ("CustomHFG")
End Sub
When I open the workbook, it does not activate the 'CustomHFG' tab. I believe the RibbonOnLoad sub is being called as I have a debug.asset false
statement after the ribRibbon.ActivateTab ("CustomHFG")
line and it breaks here so I'm sure ActivateTab is being called.
Any suggestions as to why this is not activating the tab on open?
Thanks
来源:https://stackoverflow.com/questions/56780279/excel-ribbon-not-switching-to-tab-when-opening