0

Is there a way using officer or officedown to update an existing table in Word? I tried to add a bookmark to an entire table in Word (say "tb1_bk"), but then I don't know how I could modify it.

As I found no way to directly load it in shiny app as a dataframe to further save it after modification, I tried first to simply add a new table after my bookmarked table. However, body_add_table() needs a cursor to know where to add it. I tried cursor_bookmark(doc, "tb1_bk") but it says (as mentioned in the documentation) that Error: bookmark 'tb1_bk' does not end in the same paragraph (or is on the whole paragraph).

I understand of course this problem, but I was wondering then how I could load a table from Word with a specific bookmark to later modify it in R and save the changes back to the Word file.

Trichophyton
  • 625
  • 5
  • 21
  • I have always found it easier to load `MyReport.docx` into R , apply whatever edits and inserts you want, and export a `MyReportRev2.docx` file rather than try to tweak the contents of an existing document. – Carl Witthoft Aug 09 '23 at 17:09
  • Thanks, you are probably right. Would you know by chance if it is possible to bookmark an existing table in a Word document (one not created with any R package), add a Word bookmark and being able to load it in R (i.e., keeping the whole structure) ? I tried adding a bookmark directly in Word after selecting the whole table but it looks like it does not get recognized in R. – Trichophyton Aug 09 '23 at 18:52

0 Answers0