Convert ODT to DOC or DOCX and Vice Versa in C#, VB.NET

A file with the .ODT file extension is an OpenDocument Text document file. These files are most often created by the free OpenOffice Writer word processor program. ODT files are similar to the popular DOCX file format used with Microsoft Word. Both of the two file types can hold things like text, images, objects, and styles.

However, when you open an ODT document in Microsoft Word, the formatting of the ODT document may differ as a result of the two programs not sharing the same features. When converting ODT to DOCX or vice versa, the data and content will be converted successfully, but may not including the original formatting.

Following code snippets introduce how to convert ODT to DOC or DOCX and vice versa using Spire.Doc.

ODT to DOCX

To convert ODT to DOC, change the file extension and file format to .Doc in SaveToFile method.

[C#]
Document doc = new Document();
doc.LoadFromFile("SampleODTFile.odt");
doc.SaveToFile("output.docx", FileFormat.Docx);
[VB.NET]
Document doc = New Document()
doc.LoadFromFile("SampleODTFile.odt")
doc.SaveToFile("output.docx", FileFormat.Docx)

DOCX to ODT

To convert Doc to ODT, load a .Doc file format document when loading the source file.

[C#]
Document doc = new Document();
doc.LoadFromFile("SampleWordFile.docx");
doc.SaveToFile("output.odt", FileFormat.Odt);
[VB.NET]
Document doc = New Document()
doc.LoadFromFile("SampleWordFile.docx")
doc.SaveToFile("output.odt", FileFormat.Odt)