简体   繁体   English

在Excel中创建新标签页

[英]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.

相关问题 在Excel中从提示中搜索关键字,然后创建包含摘要第2部分的新选项卡 - Search for keyword from prompt in Excel then create new tab with summary part 2 在excel VBA中通过硒为每个谷歌搜索创建新标签 - Create new tab for each google search by selenium in excel VBA 如何使用Excel中一个选项卡上的列表在另一个选项卡中创建新列? - How do I use a list on one tab in Excel to create new columns in another tab? 宏,可从“主”选项卡中的列表在Excel中创建新的选项卡,并在每个选项卡中使用相同的名称填充单元格 - Macro to create new tabs in Excel from a list in a Master tab and populate a cell in each tab with the same name 如何打开保存在特定位置的 Excel 文件,使用 VBA 从工作表中的最后一个选项卡创建一个新选项卡 - How to open Excel file saved at specific location,Create a new tab as of last tab in a sheet using VBA Excel 宏复制现有选项卡并创建下一个日期停止工作的新选项卡 - Excel macro to copy existing tab and create a new tab with the next date stopped working SSIS-编写新的Excel选项卡 - SSIS - Write new Excel Tab Python - Win32com - 打开工作簿并为每个选项卡创建一个新的 Excel 文件 - Python - Win32com - Open Workbook & Create a New Excel File for Each Tab 在 Excel 中创建新的 Function - Create new Function in Excel EXCEL-在新标签页中打开所有链接 - EXCEL - Open all links in a new tab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM