[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 942
  • Last Modified:

How to remove a menu from Excel ?!!

Hello group,

I have written a code using COM Addin to add a new menu item on Excel menu bar. It has added a menu after "Help" menu. In the code,  I made a mistake by passing a wrong
parameter so instead of having Excel to consider the menu as a temporary item it is considered as permanent.

Now, everytime I run Excel it is there. How can I remove this item?


Regards,
ak
0
akohan
Asked:
akohan
1 Solution
 
Patrick MatthewsCommented:
Hello akohan,

Select Tools|Customize from the menu, rightclick the menu item, and select delete.

Regards,

Patrick
0
 
jeveristCommented:
Hi akohan,

Or, if this is a new item on the standard menu bar, try this:

Sub ResetWorksheetMenu()
     Application.CommandBars("Worksheet Menu Bar").Reset
End Sub

Jim
0
 
akohanAuthor Commented:


Hi Jim,

Thanks for your response. This must have a different approach since it doesn't go away this way. This is a custom menu item I added by a code. I tried your advice but didn't work.


Any comments?

Regards,
ak
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
akohanAuthor Commented:


This is what I have done:

               ExcelApp.CommandBars(1).Controls.Add(Type:=msoControlPopup, Temporary:=False)

As you see, I didn't pay attention first and passed False instead of True in the 2nd argument.



Any suggestions?

Thanks.
ak
0
 
jeveristCommented:
ak,

It should work.  CommandBars(1) is the same as CommandBars("Worksheet Menu Bar").  Here's a sample rotine that adds a new control to the Worksheet Menu Bar (like you did) and then resets it back.

Sub ResetWorksheetMenu()
Dim ExcelApp As Excel.Application, cb As CommandBarControl

Set ExcelApp = Application

Set cb = ExcelApp.CommandBars(1).Controls.Add(Type:=msoControlPopup, Temporary:=False)

cb.Caption = "New Menu Item"
cb.Visible = True
   
ExcelApp.CommandBars(1).Reset

End Sub

Try this and let me know how it works for you.

Jim
0
 
akohanAuthor Commented:

Hi again Jim,

I ran the code as you said "ExcelApp.CommandBars(1).Reset" but still it is there!!!

The thing is that I have " Adobe PDF" menu too and it always appears when Excel is done with its own menus, I can see a tiny delay and my menu had same behviour but since I added them as permanent they just come up exactly with the speed of regular Excel menu items. it is like the menu now is part of Excel menu :) so confusing.

Thanks.
0
 
akohanAuthor Commented:


Hi,

Ok now it is solved. I used the "Detect and Repair" under Help in Excel. It solved the issue and created a new menu. had never used it before!

Thanks,
ak
0
 
Vee_ModCommented:
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now