AW: Ribbon-Button (de-)aktivieren
28.09.2015 12:09:55
mumpel
Hallo!
Kein Problem.
In "DieseArbeitsmappe":
Private Sub Workbook_Open()
bolButton2 = True
bolButton1 = False
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 15 - mit VBAHTML 12.6.0
In ein allgemeines Modul:
Option Explicit
Public objRibbon As IRibbonUI
Public bolButton1 As Boolean
Public bolButton2 As Boolean
Public Sub onload(ribbon As IRibbonUI)
Set objRibbon = ribbon
End Sub
Public Sub onAction_Button1(control As IRibbonControl)
MsgBox "Button " & control.ID & " gedrückt"
bolButton1 = True
bolButton2 = False
objRibbon.Invalidate
End Sub
Public Sub onAction_Button2(control As IRibbonControl)
MsgBox "Button " & control.ID & " gedrückt"
bolButton1 = False
bolButton2 = True
objRibbon.Invalidate
End Sub
Public Sub getEnabled_Button1(control As IRibbonControl, ByRef enabled)
If Not bolButton1 Then enabled = True
End Sub
Public Sub getEnabled_Button2(control As IRibbonControl, ByRef enabled)
If Not bolButton2 Then enabled = True
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 15 - mit VBAHTML 12.6.0
RibbonX-Code:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="onload">
<ribbon>
<tabs>
<tab id="tab0" label="Test">
<group id="grp0" label="test">
<button id="btn0" label="Button1" size="large"
getEnabled = "getEnabled_Button1"
onAction="onAction_Button1" imageMso="_1" />
<button id="btn1" label="Button2" size="large"
getEnabled = "getEnabled_Button2"
onAction="onAction_Button2" imageMso="_2" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 15 - mit VBAHTML 12.6.0
Gruß, René