views:

3864

answers:

3

i'm looking for a way to programatically convert word documents in docx format to doc format without using ole automation. i already have a windows service that does this but it means installing office on a server and it is a little unreliable and not supported. i am aware of the aspose.words product, and i will try it out, but has anyone any recommendations for how to do this as simply, reliably, and cheaply as possible?

+7  A: 

Hi Adam,

One option without using OLE automation would be to wrap the converter dlls coming with compatibility pack in order to convert from docx to doc without automating Office.

This requires only that the Compatibility Pack of Office is installed on the machine.

The Office converter dlls convert from the document format that they support to RTF and/or from RTF to their document format using the interface ForeignToRtf/RtfToForeign. You can chain converters as you wish to convert from one format to another, e.g. to do a conversion DOCX -> RTF -> DOC.

You can get the SDK from Microsoft: http://support.microsoft.com/?scid=kb%3Ben-us%3B111716&x=16&y=7 which includes several samples on how to use existing converters. If I remember correctly there is already a command line wrapper sample included. Everything is C/C++ stuff.

You can find out which of the converter dlls are responsible for OpenXML conversion by looking at the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Text Converters\Import\Word12

Let me know if you need further details on this.

Regards, divo

0xA3
JTtheGeek
A: 

You could use docx4j (or indeed, just poi) to read the docx, and poi to write it out as a .doc

plutext
A: 

You can use our product Aspose.Words, conversions between Microsoft Word document formats are quite good I think.

romeok