XLA ドキュメントを使用して Excel のツールバーを作成するにはどうすればよいですか?
3000 次
2 に答える
3
ツールバーを作成するには、onload イベントで次のようにします。
Dim myBar As CommandBar, myButt As CommandBarControl
'Delete the toolbar if it already exists'
On Error Resume Next
CommandBars("My Toolbar").Delete
On Error Goto 0
Set myBar = CommandBars.Add(Name:="My Toolbar", _
Position:=msoBarFloating, Temporary:=True)
myBar.Visible = True
' Create a button with text on the bar and set some properties.'
Set myButt = ComBar.Controls.Add(Type:=msoControlButton)
With myButt
.Caption = "Macro1"
.Style = msoButtonCaption
.TooltipText = "Run Macro1"
.OnAction = "Macro1"
End With
' Create a button with an image on the bar and set some properties.'
Set myButt = ComBar.Controls.Add(Type:=msoControlButton)
With myButt
'the faceId line will let you choose an icon'
' If you choose to use the faceId then the caption is not displayed'
.FaceId = 1000
.Caption = "Icon Button"
.TooltipText = "Run Macro2"
.OnAction = "Macro2"
End With
礼儀正しいことは、終了時にツールバーも削除することです。
于 2008-11-04T16:18:36.143 に答える
1
これがあなたが探しているものかどうかはわかりませんが、これが役立つかもしれないと思いました:
Excel のバージョンを指定していないため、これが機能するかどうかはわかりませんが、おそらく良い出発点となるでしょう。
于 2008-11-04T16:15:50.207 に答える