【发布时间】:2019-11-22 20:45:08
【问题描述】:
我正在研究一种解决方案,以更改具有相似结构的多个 Word 文档中的文本。我要更改的文本位置是 1。在与页眉/页脚和第一个页脚中的第二个相关的文本字段中。我不知道如何处理这些元素中的文本,有人吗?有可能吗? Image of that document 这是我的例子:
library(officer)
library(magrittr)
docact <- read_docx("PATH/officertest/textfieldfooter.docx")
docx_summary(docact)
doc_index content_type style_name 文本级别 num_id 1 1 段 NA 这里是一些易于处理和操作的其他文本。不不不
cursor_reach(docact, keyword = "I want to address this textfield") %>%
slip_in_text("This is the text that I want to add ", pos = "after", style = "Default Paragraph Font")
给出一个错误:我想解决这个文本字段在文档中没有找到
headers_replace_all_text(docact, "footertext", "the text that should be the replacement",
only_at_cursor = FALSE,
warn = TRUE)
警告信息: 1: 在 header$replace_all_text(old_value, new_value, only_at_cursor, : 在文档中找到 0 个“footertext”实例。 2: 在 header$replace_all_text(old_value, new_value, only_at_cursor, : 在文档中找到 0 个“footertext”实例。 3: 在 header$replace_all_text(old_value, new_value, only_at_cursor, : 在文档中找到 0 个“footertext”实例。
【问题讨论】: