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

被刻印的时光 ゝ 提交于 2020-01-10 04:20:09

问题


I'm using Excel 2007, and I have an Excel workbook with a custom toolbar attached. Every time I open the workbook, the toolbar appears on the ribbon under "Add-ins". I can right-click on the toolbar and choose Delete Custom Toolbar and that removes it. But when I re-open the workbook, it re-appears. How do I remove it for good?

The toolbar is not created by VBA. It was attached to the workbook in an earlier version of Excel using the steps outlined in http://office.microsoft.com/en-us/excel/HP051986401033.aspx.


回答1:


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



回答2:


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



回答3:


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.




回答4:


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




回答5:


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)




回答6:


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...




回答7:


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).




回答8:


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.




回答9:


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 



回答10:


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.




回答11:


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?



来源:https://stackoverflow.com/questions/830840/how-do-i-remove-a-custom-toolbar-from-an-excel-workbook

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