_Explorers.NewExplorer event not firing for every new explorer

V

vidishasharma

Hi ,

In OnStartupComplete I added

_Explorers.NewExplorer += new
Outlook.ExplorersEvents_NewExplorerEventHandler(_Explorers_NewExplorer);

however whenever I click a new explorer this does not get fired.

I want to add my toolbar in every new explorer if user opens a new
explorer.
 
K

Ken Slovak - [MVP - Outlook]

Is _Explorers declared at a class level or other scope level so it's not out
of scope or garbage collected by the time you open the new Explorer?
 
V

vidishasharma

Hi Ken,

I have declared _Explorers in the connect class and globally
public class Connect : Object, Extensibility.IDTExtensibility2
{
private Outlook.Application applicationObject;
private object addInInstance;
Outlook.Inspectors _Inspectors;
Outlook.Explorers _Explorers;
}

I have also written a wrapper class for explorer .

The funcitionality behaves correctly for every new inspector however
for explorer it does not work
 
K

Ken Slovak - [MVP - Outlook]

From what you showed it doesn't look like you are instantiating the
_Explorers collection, where is the line?

_Explorers = applicationObject.Explorers;

Your applicationObject variable also should be declared at class level.
 
V

vidishasharma

Hi this is how I am initializing my inspector and explorer objects in
OnStartupComplete

public void OnStartupComplete(ref System.Array custom)
{

_Inspectors = applicationObject.Inspectors;

for (int i = _Inspectors.Count; i >= 1; i--)
{

WrapInspector(_Inspectors);
}
// get notified for new inspectors
_Inspectors.NewInspector += new
Outlook.InspectorsEvents_NewInspectorEventHandler(_Inspectors_NewInspector);



_Explorers = applicationObject.Explorers;

for (int i = _Explorers.Count; i >= 1; i--)
{

WrapExplorer(_Explorers);
}
// get notified for new explorer windows
_Explorers.NewExplorer += new
Outlook.ExplorersEvents_NewExplorerEventHandler(_Explorers_NewExplorer);

}

as mentioned
private Outlook.Application applicationObject;
Outlook.Inspectors _Inspectors;
Outlook.Explorers _Explorers;

are defined at connect class level.

If you have any idea what wrong I am doing please point it out.


Regards,
 
K

Ken Slovak - [MVP - Outlook]

That looks OK to me, I don't see anything that points to it not working or
why.

Is the _Explorers object valid when you run that code? No exceptions of any
kind?

Do you get any NewExplorer event firing at all at any time?
 
V

vidishasharma

No I am not getting any exception.

NewExplorer event firing never fired at all.
 
K

Ken Slovak - [MVP - Outlook]

Then I have no idea. I use similar code all the time and have never had a
problem with the NewExplorer event not firing.
 

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