Skip to contents

combine_docx() is a variant of officer::body_add_docx() that allows any number of input files and supports rdocx objects as well as Word file paths. Optionally use a separator between files or objects.

Please note that when you create a new rdocx object with this function (or officer::body_add_docx()) the added content will not appear in a summary data frame created with officer_summary() and is not accessible to other functions until the document is opened and edited with Microsoft Word. This is part of how the OOXML AltChunk Class works and can't be avoided.

Usage

combine_docx(
  ...,
  docx = NULL,
  .list = list2(...),
  pos = "after",
  sep = NULL,
  call = caller_env()
)

Arguments

...

Any number of additional rdocx objects or docx file paths.

docx

A rdocx object or a file path with a docx file extension. Defaults to NULL.

.list

Any number of additional rdocx objects or docx file paths passed as a list. Defaults to list2()

pos

where to add the new element relative to the cursor, one of "after", "before", "on".

sep

Separator to use docx files. A bare function that takes a rdocx object as the only parameter, such as officer::body_add_break or another object passed to add_to_body() as the value parameter. Optional. Defaults to NULL.

call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

Value

A rdocx object.

Examples

if (FALSE) { # \dontrun{
if (interactive()) {
  docx_path <- system.file("doc_examples", "example.docx", package = "officer")
  docx <- read_officer(docx_path)

  combine_docx(
    docx,
    docx_path
  )
}
} # }