decadence
Well-known Member
- Joined
- Oct 9, 2015
- Messages
- 525
- Office Version
- 365
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
Hi, Is there a way to use a button to clear an Editbox on a Ribbon?
Code Below...
XML:
ThisWorkbook Module:
Standard Module:
</button></editbox></checkbox></group>
Code Below...
XML:
HTML:
<group id="TestTab" label="My Testing Tab">
<checkBox id="CB1" label="Check Box Test" onAction="onActionCheck" getPressed="getPressedCheck" />
<editBox id="FBox" label="Find" onChange="onChangeCheck" getText="getTextCheck"/>
<button id="ClearFBox" label="Clear" onAction="ClearFString" imageMso="HappyFace" />
</group>
ThisWorkbook Module:
Code:
Public DocProps As CustomProperties
Public Property Let ribbonUI(iRib As IRibbonUI)
Set pRibbonUI = iRib
End Property
Public Property Get ribbonUI() As IRibbonUI
Set ribbonUI = pRibbonUI
End Property
Public Property Let CB1(b As Boolean)
On Error Resume Next
ThisWorkbook.CustomDocumentProperties("CB1") = b
If Err.Number <> 0 Then
ThisWorkbook.CustomDocumentProperties.Add Name:="CB1", LinkToContent:=False, Type:=msoPropertyTypeBoolean, Value:=b
End If
On Error GoTo 0
End Property
Public Property Get CB1() As Boolean
On Error Resume Next
CB1 = ThisWorkbook.CustomDocumentProperties("CB1").Value
If Err.Number <> 0 Then
CB1 = False
End If
On Error GoTo 0
End Property
Standard Module:
Code:
Public oRibbon As IRibbonUI
Public StrFind As String
Sub OnRibb******(ribbon As IRibbonUI)
Set oRibbon = ribbon
ThisWorkbook.ribbonUI = ribbon
StrFind = ""
End Sub
Function RefreshRibbon()
If oRibbon Is Nothing Then
'MsgBox "Error, Save/Restart your workbook"
Else
oRibbon.Invalidate
End If
End Function
Sub onChangeCheck(control As IRibbonControl, ByRef text)
StrFind = text
oRibbon.InvalidateControl (control.ID)
End Sub
Sub getTextCheck(control As IRibbonControl, ByRef text)
text = StrFind
End Sub
Private Sub getPressedCheck(ByVal control As IRibbonControl, ByRef returnID)
If control.ID = "CB1" Then returnID = ThisWorkbook.CB1
End Sub
Private Sub onActionCheck(control As IRibbonControl, pressed As Boolean)
With ThisWorkbook
.CB1 = pressed
.ribbonUI.InvalidateControl "CB1"
End With
End Sub
Public Sub ClearFString(control As IRibbonControl)
If ThisWorkbook.CB1 = True Then
'<----------- Code to clear Edit Box
End If
End Sub
Last edited: