Ribbon-Signaturen für VBA, VB6 und twinBASIC

Lies diesen Artikel und viele weitere mit einem kostenlosen, einwöchigen Testzugang.

Wer Anwendungen programmiert, die das Ribbon anpassen, möchte die benutzerdefinierten Ribbon-Steuerelemente auch mit entsprechenden Callback-Prozeduren ausstatten. Dieser Artikel liefert eine Zusammenfassung der Ribbon-Signaturen für die Callback-Funktionen unter VBA und Visual Basic 6 beziehungsweise twinBASIC. Die VBA-Signaturen nutzen wir, wenn wir Ribbon-Erweiterungen direkt zu den mit den Office-Anwendungen erstellten Ribbonanpassungen hinzufügen wollen. Erstellen wir hingegen COM-Add-Ins mit VB6 oder twinBASIC, nutzen wir die alternativen Signaturen.

Wichtige Informationen

Vorab die wichtigste Information: Verwenden Sie alle Callback-Signaturen genau so wie Sie hier abgebildet sind. Manchmal kann bereits das Hinzufügen eines Datentyps zu einem Parameter, der hier keinen Datentyp aufweist, zu Problemen führen. Wichtig ist auch, auf die korrekte Verwendung von Function/Sub zu achten. Wenn Sie twinBASIC verwenden, können Sie das Ergebnis zum Zurückgeben entweder einer Variablen mit dem gleichen Namen wie die Funktion zuweisen, oder auch die Return-Anweisung nutzen. Die erste Möglichkeit lautet also:

Function GetText(control As IRibbonControl, ByRef text) _
         As String
     ...
     GetText = strText
End Function

Die Alternative ist:

Function GetText(control As IRibbonControl, ByRef text) _
         As String
     ...
     Return strText
End Function

Hinweis zu den onAction-Alternativen

Für das button– und das toggleButton-Element gibt es je zwei Definitionen für die onAction-Prozeduren. Du kannst mit dem command-Element die Funktion eingebauter Elemente, darunter auch button– und toggleButton-Elemente, überschreiben beziehungsweise ergänzen.
Wenn Du für diese eine onAction-Prozedur hinterlegen möchtest, musst Du die Version in der folgenden Liste verwenden, hinter der in Klammern command steht. Diese Signaturen enthalten noch einen zusätzlichen Parameter, mit dem Du festlegen kannst, ob die eigentliche Funktion des Steuerelements noch ausgeführt werden soll.

Liste der Callback-Signaturen für VBA und Visual Basic 6

Button-Element

getShowImage:

VBA: Sub GetShowImage (control As IRibbonControl, ByRef showImage)
VB6: Function GetShowImage (control As IRibbonControl) As Boolean

getShowLabel:

VBA: Sub GetShowLabel (control As IRibbonControl, ByRef showLabel)
VB6: Function GetShowLabel (control As IRibbonControl) As Boolean

onAction:

VBA: Sub OnAction(control As IRibbonControl)
VB6: Sub OnAction(control As IRibbonControl)

onAction (command):

VBA: Sub OnAction(control As IRibbonControl, ByRef CancelDefault)
VB6: Sub OnAction(control As IRibbonControl, ByRef CancelDefault)

checkBox

getPressed:

VBA: Sub GetPressed(control As IRibbonControl, ByRef returnValue)
VB6: Function GetPressed(control As IRibbonControl) As Boolean

onAction:

VBA: Sub OnAction(control As IRibbonControl, pressed As Boolean)
VB6: Sub OnAction(control As IRibbonControl, pressed As Boolean)

comboBox

getItemCount:

VBA: Sub GetItemCount(control As IRibbonControl, ByRef count)
VB6: Function GetItemCount(control As IRibbonControl) As Integer

getItemID:

VBA: Sub GetItemID(control As IRibbonControl, index As Integer, ByRef id)
VB6: Function GetItemID(control As IRibbonControl, index As Integer) As String

getItemImage:

VBA: Sub GetItemImage(control As IRibbonControl, index As Integer, ByRef image)
VB6: Function GetItemImage(control As IRibbonControl, index As Integer) As IPictureDisp

getItemLabel:

VBA: Sub GetItemLabel(control As IRibbonControl, index As Integer, ByRef label)
VB6: Function GetItemLabel(control As IRibbonControl, index As Integer) As String

getItemScreentip:

VBA: Sub GetItemScreenTip(control As IRibbonControl, index As Integer, ByRef screentip)
VB6: Function GetItemScreentip(control As IRibbonControl, index As Integer) As String

getItemSuperTip:

VBA: Sub GetItemSuperTip (control As IRibbonControl, index As Integer, ByRef supertip)
VB6: Function GetItemSuperTip (control As IRibbonControl, index As Integer) As String

getText:

VBA: Sub GetText(control As IRibbonControl, ByRef text)
VB6: Function GetText(control As IRibbonControl) As String

onChange:

VBA: Sub OnChange(control As IRibbonControl, text As String)
VB6: Sub OnChange(control As IRibbonControl, text As String)

customUI

loadImage:

VBA: Sub LoadImage(imageId As string, ByRef image)
VB6: Function LoadImage(imageId As String) As IPictureDisp

onLoad:

VBA: Sub OnLoad(ribbon As IRibbonUI)
VB6: Function OnLoad(ribbon As IRibbonUI)

dropDown

getItemCount

VBA: Sub GetItemCount(control As IRibbonControl, ByRef count)
VB6: Function GetItemCount(control As IRibbonControl) As Integer

getItemID:

VBA: Sub GetItemID(control As IRibbonControl, index As Integer, ByRef id)
VB6: Function GetItemID(control As IRibbonControl, index As Integer) As String

getItemImage:

VBA: Sub GetItemImage(control As IRibbonControl, index As Integer, ByRef image)
VB6: Function GetItemImage(control As IRibbonControl, index As Integer) As IPictureDisp

getItemLabel:

VBA: Sub GetItemLabel(control As IRibbonControl, index As Integer, ByRef label)
VB6: Function GetItemLabel(control As IRibbonControl, index As Integer) As String

getItemScreenTip:

VBA: Sub GetItemScreenTip(control As IRibbonControl, index As Integer, ByRef screenTip)
VB6: Function GetItemScreentip(control As IRibbonControl, index As Integer) As String

getItemSuperTip:

VBA: Sub GetItemSuperTip (control As IRibbonControl, index As Integer, ByRef superTip)
VB6: Function GetItemSuperTip (control As IRibbonControl, index As Integer) As String

getSelectedItemID:

VBA: Sub GetSelectedItemID(control As IRibbonControl, ByRef index)
VB6: Function GetSelectedItemID(control As IRibbonControl) As Integer

getSelectedItemIndex:

Ende des frei verfügbaren Teil. Wenn Du mehr lesen möchtest, hole Dir ...

Testzugang

eine Woche kostenlosen Zugriff auf diesen und mehr als 1.000 weitere Artikel

diesen und alle anderen Artikel mit dem Jahresabo

Schreibe einen Kommentar