混合 Office 2003 / 2007 / 2010 环境中的 Microsoft Office Interop
在大多数用户使用最新版本的 MS Office,而少数用户使用较旧版本的情况下,由于机器限制,Office 2003/2007 有没有办法正确使用 Office Interop 库(而不是第三个版本)方程序集)以允许部署应用程序而无需在 2010 计算机中安装旧版本的 Office?
In a situation where most of the users are using the latest version of MS Office, and a few are using older ones, Office 2003/2007, due to machine limitations, is there a way to properly use the Office Interop libraries (and not 3rd party assemblies) to allow the application to be deployed without installing an older version of Office into the 2010 machines?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们有同样的情况,我只是使用了后期绑定
.CreateObject("Excel.Application")
,后期绑定的问题是你不会有任何智能感知,所以对我来说最好的方法是首先在引用 Office.Interop.Excel 的类上编写代码,然后将所有代码复制到使用后期绑定的另一个类中。We have the same case, I just used late binding
.CreateObject("Excel.Application")
, the thing with late binding is that you won't have any intellisense, so the best approach for me is first to write the code on a class with Office.Interop.Excel referenced, after that, Copy all the codes to the other class which use late binding.好吧,不知道是否有人还会看这个,但它就这样,工作完美!
我正是这么做的,在一台装有 Excel 2010(仅限)的机器上进行编程,并在另一台装有 Excel 2003(仅限)的机器上完美执行。 (使用 Visual Studio 2010 编程)
单击解决方案资源管理器中的“添加引用”,然后转到“.NET”部分。
将会有很多程序集,包括“Microsoft.Office.Interop.TheProgramYouWant”。
秘诀是选择旧版本 (12.0.0.0),而不是新版本 (14.0.0.0)。
它将附带“复制本地”和“特定版本”选项,均设置为 true(我没有更改它,但我不知道是否会更改某些内容)。
Well, don't know if anyone will still look at this but there it goes, works perfectly!
I did exactly that, programmed in a machine with Excel 2010 (only) and executed perfeclty in another machine with Excel 2003 (only). (Programmed using Visual Studio 2010)
Click in "add reference" at the solution explorer and go to the ".NET" section.
There will be lots of Assmeblies including "Microsoft.Office.Interop.TheProgramYouWant".
The secret is to choose the older version (12.0.0.0), not the newer (14.0.0.0).
It will come with the "copy local" and the "specific version" options both set to true (I didn't change that, but I don't know exaclty if changes something).
使用后期绑定,因为这样您就不需要在项目中引用任何 Office dll。 Outlook 后期绑定示例:
Use late binding because then you don't need to reference any Office dll's in project. Example for Outlook late binding: