Batch processing with OpenOffice

MS did a big job spreading office format worldwide. It is almost everywhere, tons, millions of files. Often it is needed to automate processing of this files. One way is to go with MS Office with VBA or OLE automation, this requires license for office and win32 system as well. Other way is to go with Open Office, which is free and reliable.

OpenOffice  has nice batch processing features which no competitors have. About them I want to tell today. I would call this feature unattended usage or open office batch procesing. And it rocks.

Strong points of OpenOffice are

  • Works on Windows OS family as well as Linux OS
  • Can open A LOT of file formats
  • It can save to many file formats
  • It can run Macros, even VBA with

Typical applications are

Imagine you have to index 1000 doc document ?

Or upload excel table to site and extract all data from it ?

Or convert 10000 document to PDF ?

OpenOffice batch usage

Lets try something simple at first time, for example how to convert DOC to PDF ?

Here is example using Office 3.1 for how to convert from MS Word DOC to Adobe PDF.

Run OpenOffice and open in main menu Tools -> Macro -> Organize Dialog -> Modules -> My Macros

Click New button and choose name: Module1.

Insert this code into module and save

To execute this macro in unattended mode run this command:

Check c:\ it should contain sample.PDF

Thats it!

You can use your editor for macros, Macro files are stored XML files, for windows look for them in

Same method works in Linux. You can do it on headless server.

This is simple case. If you want to dive deeper try to google for UNO.


  1. Hi, Rudi,this is just a general aswner, because the details depend on your operating systems and other things. In order to use those commands combined, you should a) find some basic tutorials online about shell scripting (I don’t cover it here because there are already plenty of good resources, if you use the right search query: search for shell scripting tutorial ) and then b) write all these commands in a text file, one per line, inside a shell loop that performs all those operations, in the right sequence, on all the files passed to the loop. Of course, do try this on a separate copy of your files, after having made a complete backup. Don’t be scared! the procedure is very simple, but if it is your first shell script you want to be careful, and check every step.Ciao,marco

Leave a Reply

Your email address will not be published.