How To Shut Down An Outlook Add-in

J

JRomeo

Hi:

How can I shut down an Outlook 2003 add-in for an inspector when it is
closed? Presumably this occurs in ThisAddIn_Shutdown (VSTO SE).


--
 
K

Ken Slovak - [MVP - Outlook]

Please clarify your question. What do you mean by an addin for an Inspector?
Do you want your addin to terminate when any Inspector is opened and then
closed? What happens if the user opens another Inspector? Have you tried
just releasing all of your Outlook objects and then calling Shutdown()?
 
J

JRomeo

Hi Ken.

I've created an add-in for Outlook 2003 using VS 2005 and VSTO SE. Upon
opening an Inspector of type AppointmentItem (a new or existing/recurring
appointment), a control is added to the standard toolbar, that when clicked
opens an external browser, say IE, with a given URL. Works great, except...

Upon closing the Appointment inspector, and opening another, to create an
additional appointment for example, clicking the added custom control now
opens two browser windows. Close that inspector, open another, click again,
now there's three new browser windows opened, and so on.

I'm trying to have a maximum of one browser window open. Either launch a new
one if none are open, or reuse the same one if one already does. I assumed
that I was not shutting down the add-in properly.

Here is what I use to launch IE:

System.Diagnostics.Process.Start("IExplore.exe", SomeURL);

Here is what I use when the inspector closes:

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
// Drop the NewInspector event handler
openInspectors.NewInspector -= new
Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(newInspector_Event);

// Kill the class-level objects in play
openInspectors = null;
Btn_ConfRoomSchdlr = null;
cmdBars = null;
stdBar = null;
}

Thanks for your time.
 
J

JRomeo

Ken, This has been resolved. I implemented a method to handle the
Inspector.Close event, where I removed the event handler from the added
custom control. That is...

/// <summary>
/// Handle the Inspector.Close event
/// </summary>
void closeInspector_Event()
{
// Drop the Btn_ConfRoomSchdlr event handler
Btn_ConfRoomSchdlr.Click -= new
Office._CommandBarButtonEvents_ClickEventHandler(clickButton_Event);
}


No more additional windows. Thanks for your time on this,
 

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