Adding new menu item to menu bar

  • Thread starter Saurabh Aggarwal via OfficeKB.com
  • Start date
S

Saurabh Aggarwal via OfficeKB.com

Hi

I am using your code that is used to add an explorer to the outlook. In
addition to adding explorer bar I have also added a menu bar item in my
plugin

I am using the following code to add menu to the outlook (This is in
createMenu function)
CommandBar oCommandBar = IOMCalOutlookExplorer.CommandBars["Menu Bar"];
MSO.CommandBarPopup popup = (MSO.CommandBarPopup)oCommandBar .Controls.Add
(MSO.MsoControlType.msoControlPopup,myMissing,myMissing,myMissing,1);
popup.Caption = "IO&MCal";
popup.Visible = true;

MSO.CommandBar menuCmdBarSync = popup.CommandBar;
MenuSynchronizeButton = (MSO.CommandBarButton) menuCmdBarSync.Controls.Add
(MSO.MsoControlType.msoControlButton,myMissing,myMissing,1,1);
MenuSynchronizeButton.Caption = "&Synchronize";
MenuSynchronizeButton.Click +=new
MSO._CommandBarButtonEvents_ClickEventHandler(MenuSynchronizeButton_Click);

In Onclose function I am using the following code to free the objects

MenuSynchronizeButton.Click -=new
MSO._CommandBarButtonEvents_ClickEventHandler(MenuSynchronizeButton_Click);

if(MenuSynchronizeButton != null)
{
Marshal.ReleaseComObject(MenuSynchronizeButton);
}

if ( IOMCalOutlookCommandBar != null)
{
IOMCalOutlookCommandBar.Delete ();
Marshal.ReleaseComObject (IOMCalOutlookCommandBar);
}

if(IOMCalOutlookMenuCommandBar != null)
{
IOMCalOutlookMenuCommandBar.Delete ();
Marshal.ReleaseComObject (IOMCalOutlookMenuCommandBar);
}
if (IOMCalOutlookExplorer != null)
{
Marshal.ReleaseComObject (IOMCalOutlookExplorer);
}

This is working fine in my outlook (outlook 2003)

But in Outlook2002 objects are not releasing properly. A new menubar is
added each time I open the outlook. And also after uninstalling plugin from
the system it is not removed from the outlook.

Regards
Saurabh
 
K

Ken Slovak - [MVP - Outlook]

When you add the new menu bar make it temporary. Set the Temporary property
= True.
 
S

Saurabh Aggarwal via OfficeKB.com

This is already true.
Could you please some example in c# which can add a menu item to the
menubar of the outlook and it gets disposed when we close it.

Regards
Saurabh
 

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