Office) (CommandBarButton.State 屬性
取得或設定 CommandBarButton 控制項的外觀。 讀取/寫入。
語法
運算式。狀態
需要 expression。 代表 CommandBarButton 物件的變數。
註解
內建命令列按鈕的 State 屬性是唯讀屬性。 Type屬性的值可做為msoButtonState列舉中的值。
範例
此範例會建立名為 Custom 的命令列,並在其中新增兩個按鈕。 在範例然後 msoButtonUp 左側設定] 按鈕,並且設定] 按鈕上 msoButtonDown 的權限。
Dim myBar As Office.CommandBar
Dim imgSource As Office.CommandBarButton
Dim myControl1 As Office.CommandBarButton
Dim myControl2 As Office.CommandBarButton
' Add new command bar.
Set myBar = CommandBars.Add(Name:="Custom", Position:=msoBarTop, Temporary:=True)
' Add 2 buttons to new command bar.
With myBar
.Controls.Add Type:=msoControlButton
.Controls.Add Type:=msoControlButton
.Visible = True
End With
' Paste Bold button face and set State of first button.
Set myControl1 = myBar.Controls(1)
Set imgSource = CommandBars.FindControl(msoControlButton, 113)
imgSource.CopyFace
With myControl1
.PasteFace
.State = msoButtonUp
End With
' Paste italic button face and set State of second button.
Set myControl2 = myBar.Controls(2)
Set imgSource = CommandBars.FindControl(msoControlButton, 114)
imgSource.CopyFace
With myControl2
.PasteFace
.State = msoButtonDown
End With
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。