I'm trying to automate a process that replaces some values from a Word report template. I want to find a replace certain values and below is some code that I've tried but is not working
library(RDCOMClient)
wordApp <- COMCreate("Word.Application")
wordApp[["Visible"]] <- TRUE
newfile <- "~/test_updated_Test.docx"
doc <- wordApp[["Documents"]]$Open(normalizePath(newfile))
print(doc$range()$text())
[1] "Test 123 test\r"
# this does not work
x <- wordApp$ActiveDocument()$Content()
x$Find("Test 123 test", "test7")
<checkErrorInfo> 80020003
No support for InterfaceSupportsErrorInfo
checkErrorInfo -2147352573
Error: Member not found.
# this does not work either
wordApp$ActiveDocument()$Content()$Find("Test 123 test", "test7")
<checkErrorInfo> 80020003
No support for InterfaceSupportsErrorInfo
checkErrorInfo -2147352573
Error: Member not found.
I found the following solution :