Removing menu items

Add-in Express™ Support Service
That's what is more important than anything else

Removing menu items
I can't figure out any way to remove menu items once they are created 
Steve Weixel




Posts: 14
Joined: 2005-05-04
I can't figure out any way to remove menu items once they are created. I can remove items from the appopriate controls collections but the changes are not reflected in the host application (in this case, Excel). I am adding a menu to the main menu bar in AddinInitialize, and I'm trying to remove it anywhere else outside of that event. Note that I CAN remove it after I've added it as long as I haven't left AddinInitialize.
Posted 09 May, 2005 15:14:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Steve.

In the current ADX build you can't manage controls using methods of collection. This issue will be fixed in the next build.

Why don't you use the design time to add your controls to the AddinModule?
In this case all changes are sinchronized with a host application.
Posted 10 May, 2005 16:38:36 Top
Steve Weixel




Posts: 14
Joined: 2005-05-04
Well design time is fine if everything is static but some of my menus will change as the program runs. Additionally, I have a "Close" menu item that disconnects my addin (manully, by setting COMAddinObj.Connect = False, because AddinModule doesn't seem to have a way to do it), and the designed menus are not removed either in that situation. Currently I am looping through the CommandBarObj.Controls searching for controls whos tags match the ControlTags of the controls I want to remove; and it works but its messy.
Posted 11 May, 2005 11:56:59 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Steve.

The point is that an add-in can't disconnect itself.
You can only disconnect an add-in via the Com Add-ins dialog or another add-in. In this case all command bars will be removed automatically (except Outlook).
Posted 11 May, 2005 12:51:12 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Steve, ignor my previous remark related to Outlook. If Outlook was loaded then all command bars should be removed as well.
Posted 11 May, 2005 12:59:16 Top