rnbguy

I can use the below code to create a toolbar in outlook:

try

{

// See if it already exists

this.toolbarButton = (Microsoft.Office.Core.CommandBarButton)commandBars["Standard"].Controls["SE Dial Contact"];

if (applicationObject.ActiveExplorer().CurrentFolder.FolderPath.EndsWith("Inbox"))

{

this.toolbarButton.Visible = false;

}

}

catch (Exception)

{

// Create it

this.toolbarButton = (Microsoft.Office.Core.CommandBarButton)commandBars["Standard"].Controls.Add(1, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);

if (applicationObject.ActiveExplorer().CurrentFolder.FolderPath.EndsWith("Inbox"))

{

this.toolbarButton.Visible = false;

}

this.toolbarButton.Caption = "SE Dial Contact";

this.toolbarButton.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonCaption;

}

but I want this toolbar to be created in each contact in outlook (when user double clicks a contact).... how is this done



Re: Visual Studio Tools for Office building outlook toolbar in contacts

Sue Mosher - Outlook MVP

It's done by using the Inspector window instead of Explorer. See http://www.outlookcode.com/codedetail.aspx id=797 for a code sample.





Re: Visual Studio Tools for Office building outlook toolbar in contacts

rnbguy

is there a way to do it using explorer as that is how ive set it up atm




Re: Visual Studio Tools for Office building outlook toolbar in contacts

Sue Mosher - Outlook MVP

No, a toolbar added to the Explorer window appears on the main Outlook window. The Inspector holds all toolbars for individual item windows.





Re: Visual Studio Tools for Office building outlook toolbar in contacts

rnbguy

okay ive done that now but i seem to be getting this error:

"object reference not set to an instance of an object"

and it seems to be caused by this line:

myInspectors = (Ol.InspectorsClass)myApplicationObject.Inspectors;





Re: Visual Studio Tools for Office building outlook toolbar in contacts

X4U

Hello R'n'B guy,

myInspectors should be an Outlook.Inspectors object - not an Outlook.InspectorsClass one.

Make sure that you have set the myApplicationObject before.

Also in the InspectorWrapper you should always use the Outlook.Inspector Interface - not the InstectorClass Interface.

The Inspector Interface does not provide the events.

But you can access this events like this:

((Outlook.InspectorEvents_10_Event)_Inspector).Close += new Microsoft.Office.Interop.Outlook.InspectorEvents_10_CloseEventHandler(InspectorWrapper_Close);

If it helps - on my homepage www.x4u.de is an updatetd InspectorWrapper sample.

Hope this helps,

Greets, Helmut






Re: Visual Studio Tools for Office building outlook toolbar in contacts

rnbguy

thank you so much for your reply. I will look into that tomorrow morning, howver I'm just having a look at your website now (very nice site), and id like to make sure the updated inspectorWrapper sample is in x4utools.zip names x4uinspector.cs correct




Re: Visual Studio Tools for Office building outlook toolbar in contacts

rnbguy

well in the meantime (as i cant find the updated code your refering to) I have just set myapplicationobject and the error message is gone but im diagnosing why nothing is happening in outlook, as if the code is implementing any combo box





Re: Visual Studio Tools for Office building outlook toolbar in contacts

rnbguy

its working now, some of the stuff werent set properly.

thanx again





Re: Visual Studio Tools for Office building outlook toolbar in contacts

rnbguy

hi, im curious why you said to use Outlook.Inspectors object - not an Outlook.InspectorsClass the reason I ask is becuase the utility seems to be very unstable and would like to pin point why




Re: Visual Studio Tools for Office building outlook toolbar in contacts

X4U

Hello:

this is because:

The .Net PIA's are generated by the TLBIMP Tool. This tool creates some helper classes, delegates and interfaces of the original COM Interface. the xxxxClass is such a generated helper class for internal use.

You can read more details about it in the book "Visual Studio Tools for Office" from Eric Carter and Eric Lippert.

Fact is, that the only Interfaces you should use are that which also exists in the Object Model.

I know at last 1 Problem that come up when using this helperclass instead of the original interface.

This is when you start up your addin and look for already open Explorers or Inspectors - you will get a unable to object interface exception.

When you use the original interfaces it will work.

Greets, Helmut