I am unable to replace text in a footnote (I can replace body text, and footer, but not in footnotes). Is the officer
package unable to replace in footnotes? I am open to work-arounds, other packages, etc.
abc <- "this won't be found in footnote"
read_docx(here::here("report_template.docx")) %>%
officer::body_replace_text_at_bkm("ftnt_vendor_name", abc) %>%
print(target = here::here("report_out.docx"))
I get Error: cannot find bookmark "ftnt_vendor_name"
.
I have also tried replacing text placeholder (not a bookmark), which also doesn't work in my footnote.
abc <- "this won't be found in footnote"
read_docx(here::here("report_template.docx")) %>%
officer::body_replace_all_text("vendor_name", abc) %>%
print(target = here::here("report_out.docx"))
I get Found 0 instances of 'vendor_name' in the document.
I have also tried 'slip_in_footnote` which I've never used before. I don't know how to get it to go where I want it (as opposed to the very end), and since playing with it, now I get the error that it can't move the cursor forward.
bl <- block_list(fpar(ftext(abc)))
read_docx(here::here("6. Report", "test.docx")) %>%
officer::body_add_par("Add footnote here", style = "Normal") %>%
# officer::cursor_bookmark(id = "add_ftnt02") %>%
officer::slip_in_footnote(blocks = bl) %>% #, pos = "after") %>%
print(target = here::here("6. Report", "test_out.docx"))
I get Error: cannot move forward the cursor as there is no more content in this area
This is a simple example of my issue; I need to do this for several footnotes. Any help would be appreciated!