vba 自定义工具栏中的文本框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/758515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Textbox in custom toolbar
提问by THEn
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.
是否可以将文本框控件放在 Excel 的自定义工具栏中。我创建了一个显示此工具栏的加载项。我想要做的是当用户在文本框加载项中键入时,应根据用户键入的内容调用过程或函数。
I would like to do it in VBA in MS Excel.
我想在 MS Excel 中的 VBA 中做到这一点。
Thanks.
谢谢。
采纳答案by THEn
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
回答by RedBlueThing
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:
如果您使用的是 Excel 2007 并且已经实现了 IRibbonExtensibility::GetCustomUI,那么您可以使用以下 XML 在您的插件 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>