Word Automation Backwards Compatibility With Word 2003

拟墨画扇 提交于 2019-12-12 04:14:02

问题


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.


回答1:


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

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




回答2:


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;



回答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.



来源:https://stackoverflow.com/questions/8014883/word-automation-backwards-compatibility-with-word-2003

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!