views:

360

answers:

2

Is it possible to put textbox control in custom toolbar in Excel. I have created an Add-in that shows this toolbar. What I want to do is when user types in textbox Add-in should call a procedure or function depending what user has typed.

I would like to do it in VBA in MS Excel.

Thanks.

A: 

If you are using Excel 2007 and have implemented IRibbonExtensibility::GetCustomUI then you can use the following XML to define an edit box in your Addin GUI:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"&gt;
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="MyTab" label="My Tab">
                <group id="MyGroup" label="My Group">
                    <editBox id="MyEditBox" getText="MyEditBoxCallbackgetText" label="Editbox Label" onChange="MyEditBoxCallbackOnChange"/>
                 </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>
Cannonade
That looks good. I should consider to upgrading to 2007. Thank you.
THEn
When I get a chance I can give you the code for 2003, walking out the door right now ;)
Cannonade
Thanks that would be great.
THEn
A: 

I found out.

Sub test()
    Set myControl = CommandBars("test").Controls.Add(Type:=msoControlEdit, Before:=1)
With myControl
    .Caption = Search
    .OnAction = "tester"
End With
End Sub


Sub tester()
  MsgBox "I am gonna serach for: " & CommandBars("Test").Controls(1).Text
  CommandBars("Test").Controls(1).Text = ""
End Sub
THEn