Adding new menu item to menu bar

  • Thread starter Thread starter Saurabh Aggarwal via OfficeKB.com
  • Start date 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
 
When you add the new menu bar make it temporary. Set the Temporary property
= True.
 
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
 
Back
Top