Option Explicit
Implements IRibbonExtensibility '添加对 IRibbonExtensibility 接口的引用
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
Set xlapp = Application '加载时
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
Set xlapp = Nothing '卸载时
End Sub
'调用自定义 XML
Public Function IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String
IRibbonExtensibility_GetCustomUI = GetRibbonXML()
End Function
'添加 XML 自定义代码
Public Function GetRibbonXML() As String
Dim sRibbonXML As String
sRibbonXML = "<customUI xmlns=""http://schemas. >" & _
"<ribbon startFromScratch=""false"">" & _
"<tabs>" & _
"<tab id=""hd"" label=""数据"">" & _
"<group id=""eh"" label=""数据"">" & _
"<button id=""Button1"" label=""数据1"" size=""large"" imageMso=""HappyFace"" onAction=""a1"" />" & _
"<button id=""Button2"" label=""数据2"" size=""large"" imageMso=""FormulaMoreFunctionsMenu"" onAction=""a2"" />" & _
"<button id=""Button3"" label=""数据3"" size=""large"" imageMso=""FunctionsDateTimeInsertGallery"" onAction=""a3"" />" & _
"</group>" & _
"<group id=""sh"" label=""数据"">" & _
"<button id=""Button4"" label=""数据4"" size=""large"" imageMso=""FindDialog"" onAction=""a4"" />" & _
"<button id=""Button5"" label=""数据5"" size=""large"" imageMso=""FilterToggleFilter"" onAction=""a5"" />" & _
"</group>" & _
"<group id=""fh"" label=""数据"">" & _
"<button id=""Button6"" label=""数据6"" size=""large"" imageMso=""BlogHomePage"" onAction=""a6"" />" & _
"<button id=""Button7"" label=""数据7"" size=""large"" imageMso=""HyperlinkInsert"" onAction=""a7"" />" & _
"</group>" & _
"<group id=""ch"" label=""数据"">" & _
"<button id=""Button8"" label=""数据8"" size=""large"" imageMso=""Calculator"" onAction=""a8"" />" & _
"<button id=""Button9"" label=""数据9"" size=""large"" imageMso=""DeclineInvitation"" onAction=""a9"" />" & _
"</group>" & _
"</tab>" & _
"</tabs>" & _
"</ribbon>" & _
"</customUI>"
GetRibbonXML = sRibbonXML
End Function
Public Sub a1(ByVal control As IRibbonControl)
End Sub