简体   繁体   English

C# 中单词的后期绑定

[英]Late binding of word in C#

I am developing an application which need to interact with 2003, 2007, 2010 versions of MSWord and PPT.我正在开发一个需要与 2003、2007、2010 版本的 MSWord 和 PPT 交互的应用程序。 I read some articles and found that Late binding is the best option.我阅读了一些文章,发现后期绑定是最好的选择。

Could somebody post some sample code how to do it for word and PPT?有人可以发布一些示例代码如何为word和PPT做吗?

Like how to get the running instances of application irrespective of their version?就像如何获取应用程序的运行实例,而不管它们的版本如何?

Your best bet is to use the Ms Word / PowerPoint object libraries which make the com intero really quite simple from .net.最好的办法是使用 Ms Word / PowerPoint object 库,它使 com intero 从 .net 变得非常简单。 There is a nice step by step here for the word:这个词有一个很好的步骤:

http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx

Along with the obligatory Microsoft tutorial:连同强制性的 Microsoft 教程:

http://support.microsoft.com/kb/316384 http://support.microsoft.com/kb/316384

There is a good article on late binding with COM here:这里有一篇关于与 COM 进行后期绑定的好文章:

http://www.devarticles.com/c/a/C-Sharp/Using-Late-Bound-COM-Objects/ http://www.devarticles.com/c/a/C-Sharp/Using-Late-Bound-COM-Objects/

Though you may want to heed the warning Microsoft give about the performance implications of using late binding of COM when early binding is available!尽管您可能需要注意微软给出的警告,即在早期绑定可用时使用 COM 的后期绑定对性能的影响!

Alternatively you may want to take a look at the aspose Libraries for office file manipulation if you want a nice api and prefer to avoid COM.或者,如果您想要一个不错的 api 并且更愿意避免使用 COM,您可能需要查看用于办公室文件操作的aspose 库 There pricy but I have used them extensively and find them far superior from a dev point of view.那里很贵,但我已经广泛使用它们,从开发的角度来看它们要优越得多。

NetOffice ( http://netoffice.codeplex.com ) is a free set of version-independent interop assemblies for Office. NetOffice ( http://netoffice.codeplex.com ) 是一套免费的与版本无关的 Office 互操作程序集。 It supports all Office versions and even tells you which Office versions support a particular method:它支持所有 Office 版本,甚至告诉您哪些 Office 版本支持特定方法:

NetOffice 版本信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM