Saving commanbar position in shared add-in

  • Thread starter Thread starter ian
  • Start date Start date
I

ian

I have written a shared add-in which is used in Outlook, the add-in
creates a commandbar.

I would like to save the position of the commandbar, and have project
settings to hold the necessary infomation. I want to save this
informaiton when the user closes down outlook, but I do not know the
correct place to call this code from. I have the following code:

private void SaveCommandBarSettings()
{
Properties.Settings.Default["CommandBarTop"] =
myCommandBar.Top;
Properties.Settings.Default["CommandBarLeft"] =
myCommandBar.Left;
Properties.Settings.Default["CommandBarVisible"] =
myCommandBar.Visible;
Properties.Settings.Default["CommandBarPosition"] =
(int)myCommandBar.Position;
Properties.Settings.Default["CommandBarRowIndex"] =
myCommandBar.RowIndex;
Properties.Settings.Default.Save();
}

I have tried calling this from OnBeginShutdown and OnDisconnection but
in both instances the commandbar object is not available. Does anyone
know where I am going wrong?

Thanks,

Ian
 
OnDisconnection is too late. You should call it -- along with other shutdown and cleanup code -- when the last Explorer window closes, using the Explorer.Close event. Helmut Obertanner's sample at http://www.outlookcode.com/codedetail.aspx?id=1336 shows how to set up that event handler with C#.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top