0

I am trying to add a flextable to a word document at a given bookmark.

I have created a flextable which I can display correctly and also insert it at the word document, though I want it to be included at the bookmark "Tabla33" position

Though I got the following error.

Error in xpath_search(x$node, x$doc, xpath = xpath, nsMap = ns, num_results = 1) : 
  Expecting a single string value: [type=character; extent=10].

Here is the code I am using.

    BKM<-read_docx( "myword_document.docx") %>%
      officer::cursor_reach("Table33");    doc<-read_docx( "myword_document.docx") %>%
      body_replace_flextable_at_bkm( BKM,  value = Tabla33, align = "center")
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
jdl
  • 1
  • It seems you are not providing a "bookmark id" ("Table33") but an object of class rdocx. You should use `doc<-read_docx( "myword_document.docx") %>% body_replace_flextable_at_bkm( "Table33", value = Tabla33, align = "center")` instead – David Gohel Apr 06 '20 at 07:07
  • Thanks David for your prompt response. I tried your suggestions and got the following error: Error: bookmark "Tabla33" does not end in the same paragraph (or is on the whole paragraph) `doc<-read_docx( "myword_document.docx") %>% body_replace_flextable_at_bkm( "Tabla33", value = Tabla33, align = "center")` – jdl Apr 06 '20 at 07:46
  • Then your bookmark is not ending in the paragraph where it starts... read the first paragraph of this manual https://davidgohel.github.io/officer/reference/body_replace_text_at_bkm.html – David Gohel Apr 06 '20 at 08:33

0 Answers0