bpsmicro
Guest
|
I'm looking at Add-In Express as a time-saver as we port our existing C++ COM add-ins to a C#/.NET environment. I need to clarify a couple of things with respect to integration with multiple Office versions. Let's focus on Outlook for the moment...
So I need an add-in that works on Outlook 2000, 2002 and 2003 (and of course Outlook12 but we'll worry about that later). So far, it looks like ADX produces add-ins that work on all three Outlooks. My understanding is that you need to reference the separate Outlook PIAs in order to produce an add-in that a given version of Outlook will support (ie. an add-in referencing the Outlook2003 PIA will not load in OL2002, and vice-versa).
How does ADX deal with this? Does it provide three separate "builds" of the add-in for each Outlook version from the same source, or perhaps three separate "shims"?
To complicate matters a bit, while I need the add-in to work under all three OL versions, I also need it to access some OL2003-specific properties when it's running under OL2003. More to the point, when a customer is using our add-in with OL2003, certain features will get enabled that don't exist with the older versions. So just building with the OL2000 PIA won't do the trick as a "global" solution.
Comments?
Brad. |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Brad.
My understanding is that you need to reference the separate Outlook PIAs in order to produce an add-in that a given version of Outlook will support (ie. an add-in referencing the Outlook2003 PIA will not load in OL2002, and vice-versa).
Not quite so. An add-in referencing the OL 2002 PIAs will work in Outlook 2003. To create an add-in that will work in all Outlook versions you need to use PIAs for Outlook 2000.
I'd like to note that Add-in Express traps all events of Outlook regardless of the PIAs version that you are using. If you want to use some OL2003-specific properties/methods, you can use the Invoke method of the Type class. It is due to the Invoke method that Add-in Express can work with any Office version without using PIAs at all.
|
|
bpsmicro
Guest
|
Okay, I believe I understand what you're saying. Basically I build using the OL2000 PIA which gets me the multi-version compatability, and in those cases where I need OL2003-specific properties, I just Invoke directly.
Do you happen to have a code fragment (C# or VB.NET would be fine) that illustrates this, just so I'm crystal clear on the concept?
Thanks;
Brad. |
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Brad, this is a fragment of the ADX code.
internal Microsoft.Office.Core._CommandBars GetAppCommandBars()
{
if (applicationType != ADXOfficeHostApp.ohaMapPoint)
{
try
{
if (applicationType == ADXOfficeHostApp.ohaOutlook)
{
object dispInspectors = null, dispExplorers = null, activeWindow = null;
try
{
dispExplorers = applicationObject.GetType().InvokeMember(
"Explorers",
BindingFlags.GetProperty, null, applicationObject, null);
dispInspectors = applicationObject.GetType().InvokeMember(
"Inspectors",
BindingFlags.GetProperty, null, applicationObject, null);
int inspectorsCount = 0, explorersCount = 0;
if (dispExplorers != null)
{
explorersCount = Convert.ToInt32(dispExplorers.GetType().InvokeMember(
"Count",
BindingFlags.GetProperty, null, dispExplorers, null));
}
if (dispInspectors != null)
{
inspectorsCount = Convert.ToInt32(dispInspectors.GetType().InvokeMember(
"Count",
BindingFlags.GetProperty, null, dispInspectors, null));
}
if (inspectorsCount > 0 || explorersCount > 0)
{
object dispCommandBars = null;
activeWindow = applicationObject.GetType().InvokeMember(
"ActiveWindow",
BindingFlags.GetProperty, null, applicationObject, null);
if (activeWindow != null)
{
dispCommandBars = activeWindow.GetType().InvokeMember(
"CommandBars",
BindingFlags.GetProperty, null, activeWindow, null);
if (dispCommandBars != null)
return (dispCommandBars as Microsoft.Office.Core._CommandBars);
}
}
}
finally
{
if (activeWindow != null)
Marshal.ReleaseComObject(activeWindow);
if (dispInspectors != null)
Marshal.ReleaseComObject(dispInspectors);
if (dispExplorers != null)
Marshal.ReleaseComObject(dispExplorers);
}
}
else
{
return applicationObject.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, applicationObject, null) as Microsoft.Office.Core._CommandBars;
}
}
catch
{
//DoError(this, e);
}
}
return null;
}
|
|