Explorer' Close event not fired

  • Thread starter Thread starter j
  • Start date Start date
J

j

Hi All,

I have Outtlook Addin (C# 2.0, VSTO 2005, Outlook 2003),

i subscribed to close event:

explorerEvents.Close += new
Outlook.ExplorerEvents_10_CloseEventHandler(OnExplorerClose);

but i never get there, why???

Only if i open another explorer (right click on folder--> Open in new
folder), and close it , then i get the close event fired, but when i
have only one explorer (main explorer) it's seem to be never fired.



P.S. I also susbscribe to FolderSwitch and SelectionChange explorer
events , they works fine.

Any suggestions??
 
It sounds like you're not subscribing to the correct Explorer's events and
that you're not using a wrapper collection for open Explorers. If you were
you wouldn't get Close on the first Explorer after opening a second
Explorer.

Are you getting ActiveExplorer and subscribing to that in the Startup event
handler in your VSTO addin?

FWIW I do get all Explorer events including on the first Explorer and
separate events in my Explorer wrappers for each Explorer event I subscribe
to including Close().
 
Thanks,

It sounds like you're not subscribing to the correct Explorer's events and
but also i subscribed to FolderSwitch, and SelectionChange events, and
they fires well.
that you're not using a wrapper collection for open Explorers. If you were
you wouldn't get Close on the first Explorer after opening a second
Explorer.
Sorry probably i didn't explain right my problem, but if open another
explorer (NewWindow) on this just opened explorer
on closing it teh Close event will fire. On main explorer (explorer
that i get when Outlook is starts) i never get close event.

Are you getting ActiveExplorer and subscribing to that in the Startup event
handler in your VSTO addin?
Yes that exactly what i'm doing.



Any other suggestions??, Things that i should check??


Thanks in Advance.
 
Not offhand. Post the parts of the code you're using to set up your Explorer
events handlers. Maybe we'll see something.
 
Thanks,

outlookExplorer is hold reference to Explorer

Outlook.ExplorerEvents_10_Event explorerEvents =
(Outlook.ExplorerEvents_10_Event)outlookExplorer ;

explorerEvents.Close += new
Outlook.ExplorerEvents_10_CloseEventHandler(OnExplorerClose);
explorerEvents.FolderSwitch += new
Outlook.ExplorerEvents_10_FolderSwitchEventHandler(explorerEvents_FolderSwitch);
explorerEvents.SelectionChange += new
Outlook.ExplorerEvents_10_SelectionChangeEventHandler(explorerEvents_SelectionChange);


thats All, tnx
 
And this is called in your Startup() event handler? And outlookExplorer is
declared at class level and not in the procedure? What you show looks OK to
me.

I usually test for something like this:

if(Outlook.ActiveExplorer() != null)
{
outlookExplorer = Outlook.ActiveExplorer();

// then I add the Explorer events
}
 
Thanks,

And this is called in your Startup() event handler?
Yes this is exactly what i'm doing, and outlookExplorer is declared at
class level.


Another suggestions???


Thanks in Advance.
 
The only other things I can think of is for you to show more of your code,
the complete Startup() event handler where you are instantiating your
Explorer event handler and the event handler itself. Maybe that will show
something, or to go to look at the Explorer handler sample in C# at
http://www.outlookcode.com/codedetail.aspx?id=789 and see how that compares
to your code.

The code I use is similar to Helmut's code in his Explorer wrapper example
referenced above.
 
Thanks,

I created new Addin that have nothing besides subscribing to
BeforeFolderSwitch and Explorer close events:


public partial class ThisApplication
{

Outlook.ExplorerClass expl;



private void ThisApplication_Startup(object sender, System.EventArgs
e)

{

expl = this.ActiveExplorer() as Outlook.ExplorerClass;


expl.ExplorerEvents_10_Event_Close += new
Microsoft.Office.Interop.Outlook.ExplorerEvents_10_CloseEventHandler(expl_ExplorerEvents_10_Event_Close);

exp.ExplorerEvents_Event_BeforeFolderSwitch += new
Microsoft.Office.Interop.Outlook.ExplorerEvents_BeforeFolderSwitchEventHandler(exp_ExplorerEvents_Event_BeforeFolderSwitch);



}


void exp_ExplorerEvents_Event_BeforeFolderSwitch(object NewFolder,
ref bool Cancel)
{
MessageBox.Show("Expl before folderSwitch event");
}

void expl_ExplorerEvents_10_Event_Close()

{

MessageBox.Show("Explorer Close!");

}

private void ThisApplication_Shutdown(object sender, System.EventArgs
e)
{
MessageBox.Show("Application_Shutdown");
}



All events fired but close NOT.

Technologies i'm using: .Net 2.0, Outlook 2003, VSTO 2005


Any suggestion???



Thanks in advance.
 
It looks like that's going to be normal for VSTO. I do get Explorer_Close
events even on that first Explorer, but I'm using an Explorer wrapper
collection and the close event is firing in the close handler of my
wrappers. A close in the ThisApplication class is not firing under those
conditions.
 
Back
Top