我应该引用哪个 Microsoft Word(和 Excel)互操作程序集或 DLL?

发布于 2024-10-20 20:01:49 字数 1233 浏览 1 评论 0原文

我正在使用 VB.NET 和 .NET 3.5 框架。

我正在尝试使用各自的 PIA 来自动化 word 和 excel 以获得智能感知帮助,然后(因为用户没有安装 PIA 程序集/DLL)删除引用,以便它将作为 COM 对象调用工作而不会引发错误。

我找到了这篇文章: http://msdn.microsoft.com/en-us/library/15s06t57。 ASPX 但它并不能真正帮助我确定应该使用哪个版本的程序集/DLL。当我去添加引用时,我看到类似这样的内容:

first pane

然后

第二个窗格

然后

第三个窗格

注意所有这些突出显示的听起来很相似,并且有多个版本的程序集。我开始的链接建议与产品版本相关的 DLL 名称(例如 WORD 版本 12 --- Microsoft.Office.Interop.Word.dll),但没有说明其版本 PIA 大会。那么我如何知道该使用哪一个?

还有一个更好的问题:为什么这不是明显某处?我只想让 Microsoft 说“嘿,您想使用 Word 2007 自动进行邮件合并吗?使用[在此处插入有意义的 DLL 名称(PIA 或“工具”程序集?)]。顺便说一下,您可以在此处获取该 DLL [ “此处”超链接到我需要的下载]。使用可能安装了 2007 或 2010 的计算机?请确保您拥有这两个 DLL(如果是这种情况),以下是测试方法:[插入有用的信息] (例如

“对于 Word 14(即 Word 2010),使用 Microsoft.Office.Interop.Word DLL 版本 12.0.0.0”(是这样吗?我不知道。))应该是显然,但似乎并非如此。

也许DLL的版本与程序的版本相同? Word DLL 版本 12.0.0.0 =?= WORD 版本 12)

也许我想得太多了,但对我来说仍然不太明显,如果你能回答第一个问题,我会很高兴,但如果你能解释这两个问题,那会更好。

I'm using VB.NET and the .NET 3.5 framework.

I am trying to automate word and excel using their respective PIAs to get intellisense help, then (since the users don't have the PIA assemblies/DLLs installed) remove the references so that it will work as a COM object call without throwing an error.

I found this article:
http://msdn.microsoft.com/en-us/library/15s06t57.aspx
but it doesn't really help me with what version of the assembly/DLL I should use. When I go to add a reference I see something like these:

first pane

then

Second pane

then

third pane

Notice all of these highlighted ones all sound similar and there are multiple versions of the assembly. The link I started with suggests the name of the DLL in association to the product version (like WORD version 12 --- Microsoft.Office.Interop.Word.dll) but doesn't say what version of the PIA assembly. So how do I know which one to use?

And a better question: why is this not OBVIOUS somewhere? All I want is Microsoft to say "hey, you want to automate a mail merge with Word 2007? Use [insert meaningful DLL name here (PIA or "tools" assembly?)]. By the way, you can get that DLL here ["here" hyper-linked to the download I need]. Working with computers that may have 2007 or 2010 installed? Make sure you have both DLLs (if that is the case), and here is how you test for it: [insert helpful example].

(e.g. "For Word 14 (i.e. Word 2010), use the Microsoft.Office.Interop.Word DLL version 12.0.0.0" (is this the case? I don't know.)) That should be obvious, and it does not appear to be so.

Maybe it is obvious? Is the version of the DLL the same as the version of the program? (i.e. Microsoft.Office.Interop.Word DLL version 12.0.0.0 =?= WORD version 12)

Maybe I am over-thinking this, but it is still not obvious to me. I'll be happy if you can answer the first question, but if you can explain both, that would be better.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

假情假意假温柔 2024-10-27 20:01:49

比利基本上回答了您的问题

Office 2010=14.xxx

Office 2007=12.xxx

Office 2003=11.xxx

Office xp=10.xxx

在此之前,没有任何 PIA,因此您必须自己制作。

Billy basically answered your question

Office 2010=14.x.x.x

Office 2007=12.x.x.x

Office 2003=11.x.x.x

Office xp=10.x.x.x

Before that, there weren't any PIA's so you'd have to make your own.

剧终人散尽 2024-10-27 20:01:49

使用类浏览器查看您添加的 DLL 是否公开了您想要的功能(就像您对您添加的所有其他引用所做的那样)。

为什么这在某处不明显?

那么,您希望将 Office 集成创建的所有内容记录在某处吗?这没有道理!

Use the class browser to see if the DLL you add exposes the functionality you want (just like you do for every other reference you ever add.

why is this not OBVIOUS somewhere?

So, you want everything you could possibly ever create with the office integration documented somewhere? That doesn't make sense!

伴我心暖 2024-10-27 20:01:49

有很多方法可以剥猫皮,称为“我如何知道哪个物体剥了 X 皮”。

  1. 使用对象浏览器并搜索您想要的方法。
  2. 对其进行编码,然后一次添加一个程序集 - 缓慢且低效,但它可以工作

至于找出特定位,Microsoft MSDN、支持等都有资源。例如,对于邮件合并,我发现:
http://support.microsoft.com/kb/301659

遵循参考资料相当容易如果邮件合并是问题,则代码。

至于“为什么这在某处不明显”的评论:Word 对象有相当详细的记录。也许达不到您希望自动化智能感知的水平,但在我看来,这是一个边缘案例。我从 1.0 版本发布之前就开始对 .NET Framework 进行编程,并且还没有针对您正在做的事情的业务案例。我也不知道有谁有过这种类型的商业案例。遵循 80/20 规则,我并不感到惊讶,没有对此进行指导练习……甚至没有完整的文档。

There are plenty of ways to skin the cat known as "how do I know which object does X".

  1. use the object browser and search for the methods you desire.
  2. Code it and then add assemblies one at a time - slow and inefficient, but it works

As for figuring out particular bits, Microsoft MSDN, Support, etc all have resources. For mail merge, for example, I found this:
http://support.microsoft.com/kb/301659

It is fairly easy to follow references for the code, if mail merge is the issue.

As for the "why is this not obvious somewhere" comment: The Word obects are fairly well documented. Perhaps not to the level you wish to automate Intellisense, but this is a fringe case, IMO. I have been programming the .NET Framework since before the 1.0 release and have yet to have a business case for what you are doing. I also don't know of anyone who has had this type of business case. Following the 80/20 rule, I am not surprised there is not a handholding exercise on this one ... or even full documentation.

梦年海沫深 2024-10-27 20:01:49

它位于文档中,例如 文档类

命名空间:Microsoft.Office.Interop.Word
程序集:Microsoft.Office.Interop.Word(在 microsoft.office.interop.word.dll 中)

如果它对其他程序集有任何依赖项,那么它应该将它们添加到自身中,否则它可能会在运行时提示您添加它们。

我不确定是否有明确的指南来选择哪个,但我会选择

  • 最旧版本的 Microsoft.Office.Interop.Word,它包含您需要的所有功能,因此您可以与尽可能多的 Word 版本兼容更
  • 喜欢使用正确的 .NET 版本构建的程序集 - 我已经看到 1.1 程序集与 4.0 的问题(尽管不是 Interop 程序集),但我认为通常 1.1 与 2.0(= 3.5 的运行时版本在盖)应该没问题。

It's in the documentation, e.g. DocumentClass:

Namespace: Microsoft.Office.Interop.Word
Assembly: Microsoft.Office.Interop.Word (in microsoft.office.interop.word.dll)

If it has any dependencies on the other assemblies then it ought to add them in itself, or it might prompt you for them at runtime to add.

I'm not sure there's a definitive guide to picking which one, but I'd go for

  • the oldest version of Microsoft.Office.Interop.Word that includes all the functionality you need, so you're compatible with as many Word versions as possible
  • prefer assemblies built with the correct .NET version - I've seen problems with 1.1 assemblies against 4.0 (although not Interop assemblies) but I think generally 1.1 with 2.0 (=3.5's runtime version under the covers) should be OK.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文