THEn
THEn

Reputation: 1938

Textbox in custom toolbar

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.

Upvotes: 4

Views: 7187

Answers (2)

THEn
THEn

Reputation: 1938

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 search for: " & CommandBars("Test").Controls(1).Text
    CommandBars("Test").Controls(1).Text = ""
End Sub

Upvotes: 1

RedBlueThing
RedBlueThing

Reputation: 42522

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">
    <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>

Upvotes: 4

Related Questions