最佳答案
我正在寻找一种方式来添加一个自定义标签在 Excel 色带将携带几个按钮。我偶然发现了一些通过谷歌解决这个问题的资源,但是所有这些资源看起来都很可疑,而且极其复杂。
What is a quick and simple way to do that ? I'd like the new tab to get loaded when my VBA gets loaded into Excel..
更新 : 我尝试了 给你中的这个例子,但是在最后一条指令中出现了一个“对象必需”错误:
Public Sub AddHighlightRibbon()
Dim ribbonXml As String
ribbonXml = "<mso:customUI xmlns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">"
ribbonXml = ribbonXml + " <mso:ribbon>"
ribbonXml = ribbonXml + " <mso:qat/>"
ribbonXml = ribbonXml + " <mso:tabs>"
ribbonXml = ribbonXml + " <mso:tab id=""highlightTab"" label=""Highlight"" insertBeforeQ=""mso:TabFormat"">"
ribbonXml = ribbonXml + " <mso:group id=""testGroup"" label=""Test"" autoScale=""true"">"
ribbonXml = ribbonXml + " <mso:button id=""highlightManualTasks"" label=""Toggle Manual Task Color"" "
ribbonXml = ribbonXml + "imageMso=""DiagramTargetInsertClassic"" onAction=""ToggleManualTasksColor""/>"
ribbonXml = ribbonXml + " </mso:group>"
ribbonXml = ribbonXml + " </mso:tab>"
ribbonXml = ribbonXml + " </mso:tabs>"
ribbonXml = ribbonXml + " </mso:ribbon>"
ribbonXml = ribbonXml + "</mso:customUI>"
ActiveProject.SetCustomUI (ribbonXml)
End Sub