Question

I've successfully implemented OpenXML that takes the bookmarks within a document and replaces them. Unfortunately it only works with .docx and from what I understand .doc is not compatible with the OpenXML format.

So, what I'm wondering is if I can take that WordprocessingDocument and convert it to a .doc when users try and download it. Is that possible? If so anyone know how to do that?

Was it helpful?

Solution

Converting from DOCX to DOC with Open XML SDK 2.0 is not possible.

OTHER TIPS

Either use a third party library, like Aspose.Words. Or you need to use Microsoft Interop services.

This is sample C# code:

Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document wordDocument = wordApplication.Documents.Open(opath);
wordDocument.SaveAs("BLUH.DOC",  WdSaveFormat.wdFormatDocument);

((Microsoft.Office.Interop.Word._Document)wordDocument).Close(); // cast necessary
((Microsoft.Office.Interop.Word._Application)wordApplication).Quit(); // cast necessary

Take a look at these pages:

FileConverter

SaveFormat

SaveAs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top