将对象嵌入到 Microsoft Word 和 OpenOffice Writer 中

发布于 2024-08-17 00:16:35 字数 1539 浏览 3 评论 0原文

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

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

发布评论

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

评论(2

云仙小弟 2024-08-24 00:16:36

由于 OLE 几乎是一种史前技术(仍在使用),因此您必须在 MSDN 中深入挖掘。下面链接的文章介绍了一个可以嵌入到 IE、Word 或 OpenOffice 等容器应用程序中的示例应用程序。该示例基于 VC6,因此我不知道您需要多大的运气才能让它在当前版本的 Visual Studio 上运行。

创建 OLE 服务器


创建 OLE 控件 (.ocx) 的最简单选项可能是使用旧的 Visual Basic 6。此处对此进行了描述:

如何在 VB 中创建和使用最小的 ActiveX 组件

也可以用 C# 等托管代码编写控件,但我认为不建议这样做1,因为如果当前进程已经在运行另一个版本的 CLR(到目前为止,一个进程中只能存在一个版本的 CLR,.NET 4.0 将引入 CLR 的并行执行。我找到了以下教程:

逐步在 .NET 中创建 ActiveX


< sub>1请参阅 这篇文章,作者:Andrew Whitechapel。

Since OLE is an almost pre-historic technology (still of use) you have to dig a bit deeper in MSDN. The article linked below describes a sample application that can be embedded into container applications such as IE, Word, or OpenOffice. The sample is based on VC6, so I don't know how much luck you will have to get it running with current versions of Visual Studio.

Creating an OLE Server

Probably the most simple option to create an OLE control (.ocx) is to use the old Visual Basic 6. This is described here:

How To Create and Use a Minimal ActiveX Component in VB

It is also possible to write a control in managed code like C#, but I assume this is not recommended1 as it might lead to conflicts if the current process is already running another version of the CLR (Up to now, only one version of the CLR can exist in a process, .NET 4.0 will introduce side-by-side execution of the CLR). I found the following tutorial:

Create ActiveX in .NET Step by Step

1See the warning at the bottom of this article by Andrew Whitechapel.

美男兮 2024-08-24 00:16:36

这仍然可以在 Word 中使用 COM(或 OLE,但使用新名称时效果相同)轻松完成。根据您打算使用哪种语言,您的处理方式会有所不同。本质上,您需要创建一种特定类型的 ActiveX 控件。

在 Delphi(最简单的语言)中,您可以在 COM dll 中创建一个 ActiveXForm,然后您就可以将其嵌入到您的 Word 文档中。您可以让您的应用程序在 Word 中执行您想要的任何操作(与 Word 对话的过程稍微复杂一些,但也是可能的)。

恐怕我不知道在 OpenOffice 中该怎么做。

我认为你需要带着更具体的问题回来。

This can still be quite easily done in Word using COM (or OLE but it's the same thing with a new name). Depending on what language you are intending to do it in you will go about it differently. Essentially you need to create a particular kind of ActiveX control.

In Delphi (the easiest language to do this in) you would create an ActiveXForm in a COM dll and then you would be able to embed this in your word document. You could make your application do whatever you wanted inside Word (talking to Word is a bit more involved but possible).

I have no idea what to do in OpenOffice I'm afraid.

I think you need to come back with more specific questions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文