|
数式バーが表示されている場合、ワークシートメニューバー中の表示メニューの「数式バー」の左にチェックマークが入っています。これと同じ事をオリジナルのコマンドバーで実行してみましょう。
Public MyCB2 As CommandBar
Sub ボタンを選択された状態にする()
With Application.CommandBars.Add("MyCommandBar2", msoBarTop, False, True)
.Visible = True
With .Controls
With .Add(msoControlButton)
.Style = msoButtonCaption
.Caption = "Button1"
.OnAction = "Macro1"
End With
With .Add(msoControlPopup)
.Caption = "Popup"
With .Controls
With .Add(msoControlButton)
.Style = msoButtonCaption
.Caption = "Button2"
.OnAction = "Macro2"
End With
End With
End With
End With
End With
Set MyCB2 = Application.CommandBars("MyCommandBar2")
End Sub
Sub Macro1()
With MyCB2.Controls("Button1")
If .State = msoButtonUp Then
.State = msoButtonDown
Else
.State = msoButtonUp
End If
End With
End Sub
Sub Macro2()
With MyCB2.Controls("Popup").Controls("Button2")
If .State = msoButtonUp Then
.State = msoButtonDown
Else
.State = msoButtonUp
End If
End With
End Sub
実行するとButton1は通常にない形態になっているのが分かると思います。オリジナルの雰囲気が出ていいと思いませんか? |