Question

I am using the DOCX library to manipulate *.docx files.

I would like to save a *docx file as an html file, but this code:

using (DocX sourceDoc = DocX.Create(sourceFilename))
{
    sourceDoc.SaveAs(sourceHTMLFileName); 
}

...does not work (sourceHTMLFileName is "Bla.html").

Is it possible? If so, how?

Was it helpful?

Solution

The author of DocX has stated in a blog post that his library does not support this feature yet. I got the link from the codeplex page for the library.)

Quote from the link:

I would love to add this functionality to DocX, however there is a problem.

[...]

The only easy way to do this conversion, is to use Microsoft’s Office interop libraries

[...]

Is there no way to do conversions without having Word.exe installed on my machine. I didn’t say that, I said there is no easy way. This looks very promising, now if I could only find the time.

He suggests a workaround using Interop but that might not be possible depending on your environment.

Using SaveAs with a file that ends in .html simply saves a .docx file with the wrong extension; there is no conversion done.

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