Office) (CommandBarComboBox.ListCount 屬性
CommandBarComboBox 控制項中取得清單項的目數。 唯讀。
注意事項
[!注意事項] CommandBars 用於部分的 Microsoft Office 應用程式已經由 Microsoft Office Fluent 使用者介面的新功能區元件取代。 如需詳細資訊,請參閱 Office Fluent 功能區概觀。
語法
運算式。ListCount
表達 代表 CommandBarComboBox 物件的 變數。
範例
此範例會檢查名為 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
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應