Unknown output format doc Pandoc can convert to DOCX, but not to DOC. Error: pandoc document conversion failed with error 22

library(gt)

tab_1 <-
gtcars |>
dplyr::select(model, year, hp, trq) |>
dplyr::slice(1:5) |>
gt(rowname_col = "model") |>
tab_stubhead(label = "car")

tab_1

tab_1 |> gtsave("tab_1.docx")

==> quarto preview Trial3.qmd --to docx --no-watch-inputs --no-browse

processing file: Trial3.qmd
|............................................. | 86% [unnamed-chunk-3]Unknown output format doc
Pandoc can convert to DOCX, but not to DOC.
Error:
! pandoc document conversion failed with error 22
Backtrace:

  1. global .main()
  2. execute(...)
  3. rmarkdown::render(...)
  4. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  5. knitr:::process_file(text, output)
    ...
  6. base::withRestarts(...)
  7. base (local) withRestartList(expr, restarts)
  8. base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
  9. base (local) docall(restart$handler, restartArgs)
  10. evaluate (local) fun(base::quote(<smplErrr>))

@robertprince Hi, doc is not supported as an output file format in pandoc.

To make sure (i am assuming you run your command from Rstudio which has a pandoc and quarto version included in the installation) run this:

<YOUR PATH TO RSTUDIO>/RStudio/resources/app/bin/quarto/bin/tools/pandoc --list-output-formats

from a terminal. For me the doc format is not listed hence it will throw the error message.

@vedoa Hi, thank you for a reply.

I ran your command and docx is there. I am not trying to save a doc file.

I am trying to save the gt table as a docx file. The quatro file renders properly without the tab_1 |> gtsave("tab_1.docx") code.

For reference this has been asked in multiple place