Command Bar Excel 2007

T

Troubled User

I can delete custom menu items that I create in VB by using:

Application.Commandbars(1).Controls("TheControl").Delete

However, in this file there is now a menubar (I don't know how it is being
added as I am not doing it in code) called "Print All Sheets".

I have tried to reference it by name as
Application.CommandBars.Controls("Print All Sheets".Delete but get nothing
(although this works perfect on the others that I add in VB").

I can delete it by right clicking on it and selecting "Delete Custom
Command", however it reloads itself (before my VB menu Add Ins are accessed)
when the file is reopened.

Any ideas are much appreciated.
 
J

Jim Rech

Deleting the toolbar or menubar removes it from the UI for the current
session but not from the workbook it is attached to or created by. You have
to remove it from there. If it's an attached toolbar (I know you said
menubar) there is no way to detach, as far as I know, in Excel 2007. You'd
have to do that in Excel 97-2003. If a macro is creating the menubar you'd
have to find the code and delete it.

--
Jim
|I can delete custom menu items that I create in VB by using:
|
| Application.Commandbars(1).Controls("TheControl").Delete
|
| However, in this file there is now a menubar (I don't know how it is being
| added as I am not doing it in code) called "Print All Sheets".
|
| I have tried to reference it by name as
| Application.CommandBars.Controls("Print All Sheets".Delete but get nothing
| (although this works perfect on the others that I add in VB").
|
| I can delete it by right clicking on it and selecting "Delete Custom
| Command", however it reloads itself (before my VB menu Add Ins are
accessed)
| when the file is reopened.
|
| Any ideas are much appreciated.
|
|
|
 
T

Troubled User

Thanks Jim. I have looked for the code (searching VB for "Print All Sheets")
and I get nothing. I can remove it during the session by right clicking and
selecting the "Delete Custom Command"). Seeing as I can't find where it is
coming from I just want to automated this delete process. Thanks.
 
J

Jim Rech

Seeing as I can't find where it is coming from I just want to automated
If you send me the file I'll try to figure it out. Always like a
mystery.<g>

--
Jim
| Thanks Jim. I have looked for the code (searching VB for "Print All
Sheets")
| and I get nothing. I can remove it during the session by right clicking
and
| selecting the "Delete Custom Command"). Seeing as I can't find where it
is
| coming from I just want to automated this delete process. Thanks.
|
|
|
| "Jim Rech" wrote:
|
| > Deleting the toolbar or menubar removes it from the UI for the current
| > session but not from the workbook it is attached to or created by. You
have
| > to remove it from there. If it's an attached toolbar (I know you said
| > menubar) there is no way to detach, as far as I know, in Excel 2007.
You'd
| > have to do that in Excel 97-2003. If a macro is creating the menubar
you'd
| > have to find the code and delete it.
| >
| > --
| > Jim
message
| > | > |I can delete custom menu items that I create in VB by using:
| > |
| > | Application.Commandbars(1).Controls("TheControl").Delete
| > |
| > | However, in this file there is now a menubar (I don't know how it is
being
| > | added as I am not doing it in code) called "Print All Sheets".
| > |
| > | I have tried to reference it by name as
| > | Application.CommandBars.Controls("Print All Sheets".Delete but get
nothing
| > | (although this works perfect on the others that I add in VB").
| > |
| > | I can delete it by right clicking on it and selecting "Delete Custom
| > | Command", however it reloads itself (before my VB menu Add Ins are
| > accessed)
| > | when the file is reopened.
| > |
| > | Any ideas are much appreciated.
| > |
| > |
| > |
| >
| >
 
T

Troubled User

Thanks Jim. Ended up being a Menu control that was added sometime in 2001.
It did not display in Excel 2003, but was still in the file and would display
in the Command control (although inoperable and unable to remove in code). I
saved the 2003 file as a 2007 file and it removed it. I then saved the 2007
file back as a 2003 file and everything seems to be fine.

Thanks for your efforts!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top