VBA Ribbon EditBox - How to clear contents?

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
178
Office Version
  1. 2021
  2. 2016
Platform
  1. Windows
Hi Guys and Happy New Year 2014:)

I have an editbox in my customised ribbon and it is an input for names in a list
After collecting the input the code clears the name from a list of names.

??? How can I clear the contents of the editbox at the end of the sub
Code:
Public Sub RemoveNameBox_onChange(control As IRibbonControl, Text As String)'
' Code for onChange callback. Ribbon control editBox
'
   
        
' Set sheet shortcuts
    Set pws = Worksheets("Panels")
    Set rws = Worksheets("Report")
    
    DeleteName = Text
    pws.Range("DeleteName") = DeleteName
    DeleteNameValue = pws.Range("DeleteNameValue")
    
    If pws.Range("=$AK$31") >= 1 Then
        pws.Range("=$AF$5").Select
        Selection.Offset(DeleteNameValue, 0).Select
        Selection.ClearContents

[I]'XXX want to clear the text edit box of the entry here ready for a new name XXX[/I]
        
    End If


    
End Sub

Any guidance gratefully received as always
Paul
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I expect you would need a callback in the RibbonX of the editbox that sets a routine to call to get content for the editbox. Then invalidate the ribbon at the end of the sub you showed.
 
Upvote 0
Hi Jan
The code above is my callback.
The contents of the editbox is captured on the line
DeleteName = Text ..... where DeleteLine is a string variable and Text is the editbox input
This part works fine and captures the input and transfers it to the pws sheet where is is used to delete the input name... again this works fine

at this point I exit the sub but would like to clear the input now left in the editbox.

Not clear how invalidating the ribbon at this point will clear the edibox text??
Could you elaborate on that
 
Upvote 0
You need to add a getText callback to the ribbon XML, which has this counterpart in VBA:

Public Sub Editbox1_getText(control as IRibbonControl, ByRef returnedVal)
'
' Code for getText callback. Ribbon control editBox
'

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top