我一直在关注向Outlook添加加载项功能区的教程。在我的项目中,我有MyRibbon.vb和MyRibbon.xml。我编辑了MyRibbon.xml,因此有一个按钮显示"绿色打印"。
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab idMso="TabAddIns">
<group id="MyGroup"
label="My Group">
<button id="printButton" label="Green Print" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
在MyRibbon.vb中,我添加了一些代码,我希望这些代码会显示一条消息,说明&#34; Hello World&#34;单击按钮时:
#Region "Ribbon Callbacks"
'Create callback methods here. For more information about adding callback methods, visit https://go.microsoft.com/fwlink/?LinkID=271226
Public Sub Ribbon_Load(ByVal ribbonUI As Office.IRibbonUI)
Me.ribbon = ribbonUI
End Sub
Public Sub OnActionCallback(ByVal control As Office.IRibbonControl,
ByVal isPressed As Boolean)
If (control.Id = "printButton") Then
MsgBox("Hello World!")
End If
End Sub
#End Region
然而,当我点击加载项功能区中的绿色打印按钮时,没有任何反应 - 没有错误信息或任何东西。我哪里出错了?
答案 0 :(得分:1)
您缺少XML中回调的指针。使用:
<button id="printButton" label="Green Print" onAction="OnActionCallback"/>