I would like to do the following:

  • Link to external source code file (for example a SQL script in ASCII format)
  • Automatically apply syntax highlighting to the imported text
  • Place the highlighted text inside a frame
  • Add a caption to the frame
  • Frame contents must always contain the contents of the external source

Is this possible? If so, how? I could not find any examples.

Thank you!

2 Answers 2


I see what you need. Open a .odt then go to insert->object->OLE object. Then click create from file, choose the file and check link.

Once the object is created, right click and select activate OLE object outplace Do not resize or modify until you activate. Finally, if you have the right package installed (e.g. coooder), then select all the text inside of the OLE object and click the coooder button (Looks like: <>). It'll ask you for the language.

If you change the source file then reactivating the OLE object should update the information, but I had to redo the syntax highlight every time :|

There is a handy caption button when you click on an inactive OLE object, so...

This should get you where you want to be.

  • Do you have a complete step-by-step example? What happens when you modify the source code of the file? Does OpenOffice automatically update the source code within the document? How do you get the syntax highlighting to work? Nov 17, 2010 at 19:44
  • @Dave Jarvis Honestly, I do not see how this is not a solution. Anyways, I might be giving up on SuperUser as no one seems to respond to posts.
    – jnewman
    Nov 30, 2010 at 19:47
  • @JoshN: Redoing the syntax highlighting every time (by hand) is not an option. In my situation, there are scores of source code snippets. I want to edit the source code outside of OpenOffice, then simply regenerate the documentation. The question is moot for me now as I have since ported the document from OpenOffice to LyX (LaTeX), which makes my life a lot easier. (The solution I crafted -- generating an image -- works for both OpenOffice and LyX, btw.) I do appreciate your efforts to help, though! Nov 30, 2010 at 20:04
  • I agree LaTex is a better solution for this sort of thing, but I still see this as a valid answer, hence the frustration. I am also certain that this could be done automatically using OO's powerful scripting features, so why do you claim it cannot be done?
    – jnewman
    Dec 2, 2010 at 23:52
  • @JoshN: (1) OO 3.2.1. does not have the option "activate OLE object outplace" after a right-click. (2) OO 3.2.1. fails on the install of coooder with the message "Could not create Java implementation loader". (3) The solution you propose, while great in theory, has practical issues for writing a technical document. (Such as having to reapply syntax highlighting on every change.) Dec 24, 2010 at 4:34

A work-around is to embed an image of the source code:

Convert HTML to image

From the OpenOffice users mailing list:

I expect that you will not find a fully automated working solution for your specific problem.


In a perfect world I suppose that you will setup a repository which you can then poll. Your document must then be set to update itself based on the files. Come to think of it, perhaps you can wet something so that the document can generate itself in some specified format. Seems doable if you have the skills.

  • Answering your own question with "cannot be done" instead of leaving the question unanswered is frowned upon. Marking an answer to your question implies that the question is answered, and in your case, it isn't. It would be better to leave the question unanswered so that sometime in the future someone can come along and give a proper answer. If you accept this as the answer, there is no motivation for someone to answer the question later, which makes the question itself rather useless. Please consider unchecking this answer. Dec 23, 2010 at 22:55
  • @musicfreak: I disagree. The question has been answered: it is not possible. JoshN gave the closest viable solution, but even it is riddled with problems. Until someone cares to prove me wrong, this is the correct answer. Anyone may post an answer. And if it works, then I will mark it as correct. Dec 24, 2010 at 4:38
  • Do you have a source claiming that this is not possible? If not, how do you know? There's a chance that this is very well possible, and if it is, this "answer" (or lack thereof) would be wrong. Anyway can post an answer, yes, but I would be less inclined to if I saw that the OP already accepted an answer, because that implies that you have no need for a better answer. Dec 24, 2010 at 5:16
  • @musicfreak: You have a good point: I do not have a source. I now agree with you. Dec 24, 2010 at 5:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .