How to export html from emacs org-mode that can be opened in Microsoft Word

7

I created an HTML file using Emacs (org-mode export), which I want to open in Microsoft Word. However, Word says it cannot open the file. In the details of the error message, it says:

Reference to undefined entity 'hellip'.

For lack of a better fix, I go in to the file and replace all occurrences of "&hellip ;" with "...", but then I get a similar error message for 'nbsp', and so on.

What is the simplest way to get emacs to output an org-mode file in a form that can be opened in Microsoft Word, without losing formatting?

Brian Z

Posted 2013-03-14T04:49:33.677

Reputation: 856

Is there any particular reason you want to open the HTML file in Word (as opposed to exporting as OpenOffice with gives you an .odt that Word should be able to open?) Also which version of Org are you running? M-x org-version – Jonathan Leech-Pepin – 2013-03-14T12:36:33.110

@Jonathan, The primary reason is that I do not have OpenOffice installed. Org is version 7.8.11. – Brian Z – 2013-03-15T09:15:36.813

You do not need OO installed to export to odt and import odt to word (but see my answer below). – David LeBauer – 2014-01-02T17:25:21.577

Answers

1

There are many ways to do this, since org-mode supports so many different formats, and tools like pandoc converts among most of these formats.

I am not sure of the simplest way, and I had some odd results with the direct org -> docx conversion in pandoc, i.e. pandoc -s myfile.org -o myfile.docx, but there are still plenty of other options.

One approach starting with the .html export is to open the file in a browser and then copy-paste the contents to word. This preserves formatting. Another approach, described on the org-mode mailing list involves deleting the all xml lines at the top of the .html file at the top until the first line is the <html> tag.

As mentioned in a comment, you can also export to .odt (the open office writer format). This does not require an installation of OpenOffice. I just tried it with MS Word 2013. Although I got an error that said the file could not open because of an unspecified error in content.xml line 261, it was able to recover from the error and convert the .odt file to word, preserving formatting.

David LeBauer

Posted 2013-03-14T04:49:33.677

Reputation: 700