How do I remove a custom toolbar from an Excel workbook?

放肆的年华 提交于 2019-11-29 11:41:46

While the proper solution is detaching the toolbar from the workbook, I'm not sure how that is done in Excel 2007. As a workaround, a macro can be used to delete the toolbar every time the workbook is opened:

Private Sub Workbook_Open()
    ' Delete the unwanted toolbar that is attached to this workbook.
    Dim cmdbar As CommandBar
    For Each cmdbar In Application.CommandBars
        If cmdbar.Name = "Zap" Then
            cmdbar.Delete
        End If
    Next End Sub
End Sub

I realize this is an old question, but I just found an easy solution not mentioned on here that will be of use to future viewers:

  1. Change the file's extension to ".zip"
  2. Open the archive
  3. Delete the Attachedtoolbars.bin file from the archive
  4. Close the archive
  5. Change the file's extension back to what it was originally

I found two ways wich worked for me:

  1. Open in Office 2003 and detach the custom toolbar: Tools > Customize > Tab Toolbars > Button Attach... > Delete custom toolbar in workbook

  2. Open in Office 2007 and export all Objects, Forms, Modules and Class Modules and import them into a new fresh workbook (.xlsm) You will get rid of all old garbage and all macro's still work.

If it is not VBA you could go into the registry to disable the Addin associated with the toolbar.

You can also loop through all the Commandbars in Excel.Application.CommandBars and find toolbar by its name, and delete it then. This is assuming the toolbar is stuck there from a previous session (and that the workbook/addin/etc that added the toolbar didn't remove it in the Workbook_Beforeclose event)

Or, if it is not done in VBA, you could just simply: Right click in the menu bar region, click customize In the Toolbar tab click on attach and make sure it is not attached to the workbook.

Sometimes people forget the basics...

I had the same problem with a spreadsheet which displayed a custom toolbar, then left it in my default toolbar file.

I found this solution: http://support.microsoft.com/kb/291074

In Excel 2007, the file to delete is c:\Winnt\profiles\username\Application Data\Microsoft\Excel\Excel12.xlb

Worked perfectly for me (though it deletes all custom toolbars you might have installed).

I know this question is old, but what finally worked for me is going into the bin/debug folder of my excel addin project and deleting all the files, then reloading Excel.

See the answer here:

http://msdn.microsoft.com/en-us/library/office/ff862231%28v=office.15%29.aspx

For Each bar In CommandBars 
    If bar.BuiltIn = False Then 
        bar.Delete
    End If 
Next bar 

In all likelihood, there is VBA code attached to the workbook with an onLoad event that creates the toolbar.

You'll have to go delete or disable the VBA code.

We have the same problem with the ribbon in our production 2010 Excel spreadsheets that need changes. The custom ribbon needs to be modified but it is locked at every location from we have tried to edit/remove it.

Right-clicking on the toolbar does not work since the "Customize..." selections are disabled.

Removing all the VBA code has no effect, the custom ribbon still replaces the default ribbon.

In Excel Options, the "Customize the Ribbon" controls contain no selections or are disabled.

In the VBA window under View, Toolbars, Customize, the Menu Bar toolbar is locked for editing.

We have tried to locate files on the hard disk as suggested by a few posts, but the files are not found (even the folder hierarchy does not exist).

Options off the table are editing the registry or creating entirely new files by importing objects.

Question: Why do they make it so difficult to manage the ribbon?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!