AW: [CustomUI] Ribbon-Elemente aktivieren und deaktivieren
24.01.2024 14:50:12
Alwin Weisangler
Hallo,
da muss man ein klein wenig an den Standart rumschrauben. Der Weg wäre so:
in ein allgemeines Modul:
Option Explicit
Option Private Module
Public RibbonUL As IRibbonUI
Dim aktiv As Boolean
Public Sub OnRibbonLoad(objRibbon As IRibbonUI)
Set RibbonUL = objRibbon
End Sub
'Callback for checkBox1 getPressed
Sub checkBox1_Aktiviert(control As IRibbonControl, ByRef checkBox1Val)
End Sub
'Callback for checkBox1 onAction
Sub checkBox1_Klick(control As IRibbonControl, ByRef checkBox1Val)
Select Case checkBox1Val
Case True
aktiv = True
Case False
aktiv = False
End Select
RibbonUL.InvalidateControl "editBox1"
End Sub
'Callback for editBox1 onChange
Sub editBox1_Schreiben(control As IRibbonControl, text As String)
End Sub
'Callback for editBox1 getText
Sub editBox1_Lesen(control As IRibbonControl, ByRef returnedVal)
End Sub
'Callback for editBox1 getEnabled
Sub ZeditBox1_Aktiviert(control As IRibbonControl, ByRef returnedVal)
returnedVal = aktiv
End Sub
ins Ribbon:
-------------------------
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OnRibbonLoad">
<ribbon startFromScratch="true">
<tabs>
<tab id="tab" label="Mein TAB">
<group id="group1" label="Editbox aktivieren/deaktivieren">
<checkBox id="checkBox1" enabled="true" getPressed="checkBox1_Aktiviert" onAction="checkBox1_Klick" label="Editbox Eneble/Dissable" />
<editBox id="editBox1" onChange="editBox1_Schreiben" getText="editBox1_Lesen" getEnabled="ZeditBox1_Aktiviert" label="Editbox1"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
https://www.herber.de/bbs/user/166321.xlsm
Gruß Uwe