2017-05-11 7 views
0

Ich habe das Lernprogramm zum Hinzufügen des Add-In-Menübands zu Outlook verfolgt. In meinem Projekt habe ich MyRibbon.vb und MyRibbon.xml. Ich habe MyRibbon.xml bearbeitet, also gibt es eine Schaltfläche, die "Green Print" sagt.Erstellen einer Add-In-Menübandtaste etwas tun

<?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> 

In MyRibbon.vb ich einige Code hinzugefügt haben, die ich eine Nachricht „Hallo Welt“ sagen würde angezeigt hatte gehofft, wenn die Schaltfläche geklickt wird:

#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 

Allerdings, wenn ich auf dem Grün auf Drucken Button im Add-In-Ribbon passiert nichts - keine Fehlermeldung oder irgendetwas einfach nichts. Wo gehe ich bitte falsch?

Antwort

0

Ihnen fehlt der Zeiger auf den Rückruf in Ihrem XML. Verwenden Sie:

<button id="printButton" label="Green Print" onAction="OnActionCallback"/> 
+0

Hallo - vielen Dank dafür. Ich fand auch, dass ich die Linie entfernen musste: ByVal isPressed als Boolean –