Introduction

The Windows operating system provides a technology called COM, which stands for Component Object Model. In essence, it provides a way for software components and applications to "talk to each other". That's a gross oversimplification but it gives the general idea. It's now an old technology but nevertheless it is still very powerful; over the years I've used it quite extensively for automating various publishing/production tasks. In those days it was with Perl using a module called Win32::OLE.

Of course, applications have to be written to support COM so you can think of COM-aware applications as offering a "set of services" that you can call --- many applications provide the ability to call those services from scripting languages which have support for COM (via modules/plugins etc), such as Perl, Ruby and, of course, Lua via LuaCOM. A combination of COM-aware applications and scripting languages with COM support provides a very flexible way to "glue together" all sorts of different applications to create novel automated workflows/processes.

Using COM from within scripting languages is fairly straightforward but under the surface COM is, to me anyway, a complex beast indeed. The best low-level COM programming tutorials I have ever read are published on codeproject.com, written by Michael Dunn. Here's one such tutorial Introduction to COM - What It Is and How to Use It.

LuaCOM

LuaCOM lets you use COM in your Lua scripts, i.e., it is a binding to COM. I don't know if there are freely available builds of the latest version (probably with Windows distributions of Lua), but you can download and compile the latest version from Github.

LuaCOM is a DLL (Dynamic Link Library) that you load using the standard "require" feature of Lua. For example, to start Microsoft Word from within your Lua code, using LuaCOM, you would do something like this:

Naturally, the Microsoft Office applications have very extensive support for COM and offer a huge number of functions that you can call should you wish to automate a workflow process via COM from within Lua. For example, you can access all the native equation objects within a Word document (read, write, create and convert equations...). If you have watched this video and wondered how I got LuaTeX and Word to talk to each other, now you know: LuaCOM provided the glue.

Carrying on the experiments. How well does Word render native objects to blog posts? Here are some Word charts and graphics. The images you see have been rendered by Word and then uploaded. I've not edited or altered them in any way: what you see is exactly as it was uploaded. Fairly reasonable results I'd say. Of course, SVG would be nicer but maybe one day : -~)

Word 2007 and beyond can upload content directly to blogs. So, I was curious to see how well Word can post tables to my blog. Results below, untouched and exactly as they appeared after upload.

The actual data uploaded by Word is amazingly clean/simple! I thought it would be horribly complicated but I was delighted to be wrong! Clearly, the presentation you see is affected by this site's WordPress theme CSS. Which I admit does not look that good. In the WordPress content editor, the tables look great and are easy to edit. See screenshot below.

As a way to write offline and then post to your blog, it could have its uses.