如何在XLA文档中创build工具栏?

如何使用XLA文档为Excel创build工具栏?

为了制作一个工具栏,在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 

有礼貌的事情是在出口也删除工具栏。

不知道这是你在找什么,但我认为这可能会帮助你:

Excel – macros工具栏

既然你没有指定一个Excel版本,我不确定这是否适用于你,但也许它会为你提供一个很好的起点。

Interesting Posts