Вопрос

I am working on some Word automation code in C#. I have Word 2007 installed on my own machine (Version 12.0.0.0 of Microsoft.Office.Interop.Word.dll) but I would like to support Word 2003 as a minimum (Version 11.0.0.0 of Microsoft.Office.Interop.Word.dll?).

Without having Word 2003 available to me, is there any way that I can target it so that my code is backward compatible? I can't install the PIA redistributable package without having Word 2003 installed.

Это было полезно?

Решение 3

My solution was to grab a copy of Microsoft.Office.Interop.Word.dll and office.dll from a computer with Word 2003 installed. These are only used to build against so that my code works on systems that have Word 2003. Not ideal, but it works.

Другие советы

I'm fairly sure making a bindingRedirect in app.config will do the trick.

http://msdn.microsoft.com/en-us/library/eftw1fys.aspx

If you don’t mind losing intellisense and you are using .Net 4 you can get rid of the PIA altogether by using dynamic.

Code Example:

var type = Type.GetTypeFromProgID("Word.Application");
dynamic word = Activator.CreateInstance(type);
word.visible = true;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top