Outlook-CommandBarButton not removed on calling OnBeginnShutdown

R

René Meinecke

Hi there,

i have written an Outlook XP-Add-In with Visual Studio .NET. Everything
works just fine, but there is one thing
i can´t explain:

If OnBeginnShutdown is called the Button created at OnStartupComplete isn´t
removed.

here is the code i use:

public void OnBeginShutdown(ref System.Array custom)

{

object omissing = System.Reflection.Missing.Value ;

btnAntrago.Delete(omissing);

btnAntrago = null;

appOutlook = null;

//expOutlook = null;

addInInstance = null;

} // OnBeginShutdown
 
S

Sunny

Hi, the problem is that OnBeginShutdown is invoked AFTER the last
explorer/inspector is closed, and the button is unreachable. Possible
solutions:
1. Create buttons as temporary
2. trap the OnClose event of explorer/inspector and check there if this is
the last one (application.explorers.count or something similar).

Sunny
 
R

René Meinecke

Hi,

there is no OnClose-event in class explorer/inspector.
There is only a method Close(), but i don´t know how to overwrite.

Peace René
 
S

Sunny

Hi, read this article (watch out for line wrap):

http://groups.google.com/groups?hl=...-8&q=outlook+explorer+close+event&sa=N&tab=wg

I'm pasting here a part of it:
You need to declare the Explorer object as ExplorerClass to properly handle
events. See Randy Byrne's MSDN arcticle: Building Outlook Add-ins with
VB.NET
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnout2k2/h
tml/odc_oladdinvbnet.asp] which discusses this issue.

Your code should look something like this:

private Outlook.ExplorerClass activeExplr;

........

activeExplr = (Outlook.ExplorerClass)olApp.ActiveExplorer()
activeExplr.ExplorerEvents_EventClose += new
Outlook.ExplorerEvents_CloseEventHandler(this.Explorer_Close);

Hope that helps
Sunny
 

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