如何通过VBA(Excel)在Editboxfunction区上设置文本

如何在function区编辑框中设置文本? 我无法在网上find它:/

我只能find点击事件的例子,但没有关于从一个小组设置文本。

举个例子,我想要这样的东西:

Sub settingText() editboxname = "my text" end sub 

我在这个链接find的解决scheme: http : //www.shulerent.com/2011/08/16/changing-the-value-of-an-editbox-office-ribbon-control-at-runtime/

这是我testing的一个例子,它运行良好:

 'Global Variables: Public MyRibbonUI As IRibbonUI Public GBLtxtCurrentDate As String Private Sub OnRibbonLoad(ribbonUI As IRibbonUI) Set MyRibbonUI = ribbonUI GBLtxtCurrentDate = "" End Sub Private Sub ocCurrentDate(control As IRibbonControl, ByRef text) GBLtxtCurrentDate = text MyRibbonUI.InvalidateControl (control.id) End Sub Private Sub onGetEbCurrentDate(control As IRibbonControl, ByRef text) text = GBLtxtCurrentDate End Sub Public Sub MyTest() 'Here is an example which you are setting a text to the editbox 'When you call InvalidateControl it is going to refresh the editbox, when it happen the onGetEbCurrentDate (which is the Gettext) will be called and the text will be atributed. GBLtxtCurrentDate = "09/09/2013" MyRibbonUI.InvalidateControl ("ebCurrentDate") End Sub <?xml version="1.0" encoding="UTF-8"?> <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OnRibbonLoad"> <ribbon> <tabs> <tab id="Objects" label="Objects"> <group id="grp" label="My Group"> <editBox id="ebCurrentDate" label="Date" onChange="ocCurrentDate" getText="onGetEbCurrentDate"/> </group> </tab> </tabs> </ribbon> </customUI>