Friday, April 29, 2011

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.

From stackoverflow
  • 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>
    
    THEn : That looks good. I should consider to upgrading to 2007. Thank you.
    Cannonade : When I get a chance I can give you the code for 2003, walking out the door right now ;)
    THEn : Thanks that would be great.
  • 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
    

0 comments:

Post a Comment