views:

363

answers:

2

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  A: 

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.

0xA3
You're right, it's old technology, but I see it being used in latest versions of Microsoft Office.It is just odd that there are no docs on how to do proper OLE with today's technologies.
derdev
Well, old doesn't mean it's bad or not working. It's just that the documentation is a bit old and the samples might not work with VS 2008.
0xA3
A: 

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.

Toby Allen