Best way to make an Word Addin Independent of Office/Word Version

N

NanoWizard

Does anyone know what would be the best way to go about creating a
Word Addin in .NET that could work on multiple versions of Word? From
my understanding, the interops for the different versions of Word
aren't guaranteed to work with each other. I thought about creating
an assembly that would have a bunch of a relevent interfaces needed in
this project and then based on the Word version detected dynamically
load the assembly such as

Assembly asm = Assembly.LoadFile( strFilePath );
object obj = asm.CreateInstance(
"Microsoft.Office.Interop.Word.ApplicationClass" );
IMyWordApplication WordApp = obj as IMyWordApplication;

If there is a better way to do it then to write a bunch of duplicate
Class Libraries specifically coded to a particular version of
Word/Office and then load those specific assemblies from the core
add-in, I would like to know.

Thanks in advance,
Rob
 
C

Cindy M -WordMVP-

Hi NanoWizard,

Depending on the versions of Word involved and what you want to do, the
difference between what is and is not supported in the class libraries
may not matter. If you use only "commands" that work across all target
versions of Word, incompatibility isn't strictly and issue. More a
problem is, whether the "reference" to the class library in your project
will match, or be correctly "translated to", the version of the class
library on the target system.

One possible approach is to use late-binding (everything is an
"object"), which appears to be more or less what you're suggesting. That
is slower, of course.

You might also consider creating a separate DLL for each version of
Word, package them together, and have your installation determine which
to actually install, based on the "highest" version of Word installed on
a machine (or let the user choose)? Creating the entire set of DLLs
shouldn't be a big problem, I wouldn't think, if it's only a question of
referencing the particular version of a class library.
Does anyone know what would be the best way to go about creating a
Word Addin in .NET that could work on multiple versions of Word? From
my understanding, the interops for the different versions of Word
aren't guaranteed to work with each other. I thought about creating
an assembly that would have a bunch of a relevent interfaces needed in
this project and then based on the Word version detected dynamically
load the assembly such as

Assembly asm = Assembly.LoadFile( strFilePath );
object obj = asm.CreateInstance(
"Microsoft.Office.Interop.Word.ApplicationClass" );
IMyWordApplication WordApp = obj as IMyWordApplication;

If there is a better way to do it then to write a bunch of duplicate
Class Libraries specifically coded to a particular version of
Word/Office and then load those specific assemblies from the core
add-in, I would like to know.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

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