1

I'm trying to use officer::body_replace_text_at_bkm to replace a bookmark in a Word Document with an empty space.

I have a Word document template with a bookmark like the one below.

Word Doc Template

I used the code below to replace the "space" bookmark with an empty space.

library(officer)
doc <- read_docx(path =  "Test_Add_Space_Template.docx" )
officer::body_replace_text_at_bkm(doc, 'space', ' ')
print(doc, 'Test_Add_space.docx')

However, when I run the code above, no space is added to the bookmark.

Word Doc Output

I was wondering if there is a way to replace bookmarks with empty spaces, and if not, if there was another solution.

0 Answers0