views:

96

answers:

1

How could I create embedded objects in an MS office document using Python?

I don't need anything fancy, just what one used to do in the first version of OLE: doing a copy-paste from my application into e.g. MS Word should give me an object embedded in the Word document, which I can then double-click to open a copy of my application and edit the object.

Can this be done from a Python/PyQt application (perhaps using pythoncom?) Are there any simple examples of this that can get me started?

+1  A: 

OLE compound documents enable users working within a single application to manipulate data written in various formats and derived from multiple sources. A compound document object is essentially a COM object that can be embedded in, or linked to, an existing document. As a COM object, a compound document object exposes the IUnknown interface, through which clients can obtain pointers to its other interfaces, including several, such as IOleObject, IOleLink, and IViewObject2, that provide special features unique to compound document objects.

You'll use pywin32 extensions. This COM tutorial can get you started (I hope). Most info you need will come from microsoft itself. There's a book on the subject.

nosklo
Thanks, this will get me started. Since I'm completely new to COM, it would really help to have a code example, but I haven't found one anywhere... I'll have to give it a try.
dF