OnBeginShutdown

G

Gloup

Hello,

I have an Outlook 2003 addin made with VS 2003 in C#. I have a problem with
the OnBeginShutdown event. In many example on web you can see something
like:

public void OnBeginShutdown(ref System.Array custom)
{
this.toolbarButton.Delete(System.Reflection.Missing.Value);
this.toolbarButton = null;
}

but if you use try / catch with this code, there is an error, toolbarButton
no longer exists.
I've tried to get my toolbarButton with:

toolbarButton=applicationObject.ActiveExplorer().CommandBars["Standard"].Fin
dControl(......)

but in OnBeginShutdown I've no explorers, applicationObject.Explorers.Count
= 0 !!

How can I delete my button ?

Thanks
JLE
 
G

Gloup

Ok, it's impossible in OnBeginShutdown (?).

I have a (good?) solution. I delete button in Explorer Close event :
In OnStarturComplete event:
{
.....
Microsoft.Office.Interop.Outlook.ExplorerClass
explo=(ExplorerClass)(applicationObject.ActiveExplorer());
explo.ExplorerEvents_Event_Close +=new
ExplorerEvents_CloseEventHandler(this.OnExplorerClose);
.....
}

public void OnExplorerClose()
{
try
{
this.toolbarButton.Delete(System.Reflection.Missing.Value);
this.toolbarButton = null;
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
 

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