[英]Create New Tab in Excel
I would like to create a New Tab with Custom Buttons when user opens a Macro Enabled Worksheet (.xlsm). 当用户打开启用宏的工作表(.xlsm)时,我想用自定义按钮创建一个新选项卡。 Below is code I've used previously in the ThisWorkbook module of my macro;
下面是我之前在宏的ThisWorkbook模块中使用的代码; however, the buttons display under the “Add-in” tab.
但是,按钮显示在“加载项”选项卡下。 My goal is to add the buttons under a custom tab with custom sections if possible.
我的目标是在可能的情况下在带有自定义部分的自定义标签下添加按钮。 Thank you.
谢谢。
'Stored in ThisWorkbook module of my macro
Private Sub Workbook_Open()
Dim CmdBar As CommandBar
Dim CmdBarMenu As CommandBarControl
Dim CmdBarMenuItem As CommandBarControl
Set CmdBar = Application.CommandBars("Worksheet Menu Bar")
Set CmdBarMenu = CmdBar.Controls("Tools")
On Error Resume Next
Application.DisplayAlerts = False
CmdBarMenu.Controls(Button).Delete
Application.DisplayAlerts = True
On Error GoTo 0
Set CmdBarMenuItem = CmdBarMenu.Controls.Add(Type:=msoControlButton)
With CmdBarMenuItem
.Caption = Button
.OnAction = “NameOfMyMacro"
.FaceId = 5872
.Style = msoButtonIconAndCaptionBelow
End With
End Sub
You can manually change the .XML on the user interface, or use a software which does that for you. 您可以在用户界面上手动更改.XML,也可以使用适合您的软件。
See the links below: 请参阅以下链接:
How to add a custom Ribbon tab using VBA? 如何使用VBA添加自定义功能区选项卡? http://www.contextures.com/excelribbonaddcustomtab.html
http://www.contextures.com/excelribbonaddcustomtab.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.