从Excel中删除MenuBar,ToolBar

时间:2017-09-25 05:25:56

标签: excel-vba vba excel

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

1 个答案:

答案 0 :(得分: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