Embedding objects into Microsoft Word and OpenOffice Writer

徘徊边缘 提交于 2019-12-06 10:26:12

问题


I am looking for some references on how to implement the following feature:

ability to embed objects (e.g. diagrams) into word processors and being able to edit them in their respective "mother" application

For example, MS Word and Visio work like this together, allowing the user to easily edit/tweak the diagrams after adding them to the word processor.

I am interested in how this is done on the following platforms:

  • Microsoft Word
  • OpenOffice

So far I know that:

  • Microsoft Word -- uses OLE/COM
  • Open Office -- uses UNO

Can you point me to any references, examples, books on how to approach this?

PS: Every time I try to search MSDN for this, I get the impression I am in the wrong place. =(


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2023004/embedding-objects-into-microsoft-word-and-openoffice-writer

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