I am trying to display the text Select by default in a form control combo box
. I have tried the following but doesn't seem to work. Can someone please suggest what am I doing wrong ?
我试图在窗体控件组合框中显示文本默认选择。我尝试过以下但似乎没有用。有人可以建议我做错了什么吗?
Option 1:
选项1:
Activesheet.shapes("choose_selection").text = "Select your choice"
Option 2:
选项2:
Activesheet.shapes("choose_selection").controlformat.text = "Select your choice"
but I get this error
但是我得到了这个错误
0
Set the default value in a combo box
在组合框中设置默认值
The ListIndex property sets the currently selected item using an index number. ListIndex = 1 sets the first value in the array.
ListIndex属性使用索引号设置当前选定的项。 ListIndex = 1设置数组中的第一个值。
Sub ChangeSelectedValue()
With Worksheets("Sheet1").Shapes("Combo Box 1")
.List = Array("select your choice","Apples", "Androids", "Windows")
.ListIndex = 1
End With
End Sub
Hope it would help.
希望它会有所帮助。
0
Try first defining the DropDown
object, and later on display the text in it.
首先尝试定义DropDown对象,然后再显示其中的文本。
Note: DropDown
is the VBA object that refers to Form_Control ComboBox
.
注意:DropDown是引用Form_Control ComboBox的VBA对象。
Dim drpdown As DropDown
' set the drop-down object
Set drpdown = ActiveSheet.DropDowns("choose_selection")
' modify the drop-down properties
With drpdown
.Text = "Select your choice"
End With
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2017/08/29/e55de0c0169769b1cf110e84b711aa12.html。