reddit / emacs

.org files to docx?

hacker_backup · 2022-12-12 10:26
There are lots of conversion options? but none of popular office formats. Is there any way I can export org files to docx?
IceOleg · 2022-12-12 10:38
[Pandoc](https://pandoc.org/) should be able to do it.
yal_g · 2022-12-12 10:40
Org can export to ODT (which is Libreoffice/Openoffice native file format, and which is supported by MS Word). For docx, if going through LibreOffice was not an option to get that docx file, I'd use pandoc: pandoc MyFile.org -o MyExportedFile.docx. But I've never used pandoc for that, so no idea how good a job it would do.
danderzei · 2022-12-12 10:47
(setq org-odt-preferred-output-format "doc")
GreenSubstantial4469 · 2022-12-12 13:11
`pandoc`
HM0880 · 2022-12-12 13:29
Yep. Here's how I use Pandoc (on Debian). (defun hm/convert-org-to-docx-with-pandoc () "Use Pandoc to convert .org to .docx. Comments: - The `-N' flag numbers the headers lines. - Use the `--from org' flag to have this function work on files that are in Org syntax but do not have a .org extension" (interactive) (message "exporting .org to .docx") (shell-command (concat "pandoc -N --from org " (buffer-file-name) " -o " (file-name-sans-extension (buffer-file-name)) (format-time-string "-%Y-%m-%d-%H%M%S") ".docx")))
attento_redaz · 2022-12-12 14:28
I'd also recommend using Pandoc for docx export, but via the Pandoc Org exporter, `ox-pandoc`, which you can install from MELPA.
SoTypicalNoob · 2022-12-12 15:26
>org-odt-preferred-output-format I didn't know about this. I just wanted to refer ox-pandoc, but I think this is far better solution. I had some issues with pandoc. I was not able to solve to have TOC and numbering of chapters. ODT was better formatted out of the box, and seemed superior. So far I exported to ODT, and used LibreOffice to convert it to docx. This parameter is a game changer. :-)
sudeenhux · 2022-12-12 17:44
ox-pandoc all the way
hacker_backup · 2022-12-12 17:56
This is exactly what I needed, thank you. Is there a way to add this to the `C-c C-e` menu org mode has?
danderzei · 2022-12-12 22:04
It basically instructions LibreOffice to convert your file. So Libreoffice needs to be available.
HM0880 · 2022-12-12 22:53
I am sure there is a way, but my method is to define an alias: `(defalias 'd 'hm/convert-org-to-docx)`. Then a simple `M-x d RET` is the entire command!