【问题标题】:Delete MenuBar, ToolBar from excel从excel中删除MenuBar、ToolBar
【发布时间】:2017-09-25 16:47:05
【问题描述】:

在 excel 中,我想给一个按钮,该按钮删除自定义工具栏和菜单栏和工作表,所以任何人都可以建议 vba 宏从 excel 中删除工具栏或图片中标记的选项卡???
enter image description here

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    这类问题已经讨论过堆栈溢出点击here

    根据您的情况尝试以下代码

        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Code start from here
    Private Sub Workbook_Open()
        ' Delete the unwanted toolbar 
        Dim cmdbar As CommandBar
        For Each cmdbar In Application.CommandBars
            If cmdbar.Name = "Universal Template" Then '<--- ToolBar name
                cmdbar.Delete
            End If
        Next
    End Sub
    'Code end here
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    
        '''or Try this
    Sub RemoveCustomizeToolBars()
    
    For Each bar In CommandBars
        If bar.BuiltIn = False Then
            bar.Delete
        End If
    Next bar
    
    End Sub
    

    【讨论】:

    • 我尝试了这个代码。在第一个代码中,我显示所有 cmdbar.name 它包含通用模板和所有选项卡中存在的所有按钮
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多