ListCount 属性
优质
小牛编辑
125浏览
2023-12-01
全部显示
返回指定命令栏组合框控件中列表项的数目。Long 类型,只读。
示例
本示例可实现的功能为:查看命令栏“Custom”上某组合框控件中的项数。如果过程所产生的列表中包含的项数小于三,则显示一条消息提示用户组合框可能已损坏并要求重新安装应用程序。
Set myBar = CommandBars _
.Add(Name:="Custom", Position:=msoBarTop, _
Temporary:=True)
With myBar
.Controls.Add Type:=msoControlComboBox, ID:=1
.Visible = True
End With
With CommandBars("Custom").Controls(1)
.AddItem "Get Stock Quote", 1
.AddItem "View Chart", 2
.AddItem "View Fundamentals", 3
.Caption = "Stock Data"
.DescriptionText = "View Data For Stock"
End With
If CommandBars("Custom").Controls(1).ListCount _
<> 4 Then
MsgBox ("ComboBox appears to be damaged." & _
" Please reinstall.")
End If