R/rlo_parstyle.R

Defines functions rlo_parstyle

Documented in rlo_parstyle

#' Apply a paragraph style if it exists
#'
#' @importFrom PythonInR pyExec pyGet
#' @param parstyle The name of the paragraph style to be applied
#' @param warn Should missing paragraph styles give a warning?
#' @export
rlo_parstyle <- function(parstyle, warn = TRUE) {
    pyExec("parstyles = doc.StyleFamilies.getByName('ParagraphStyles')")
    if (pyGet(paste0("parstyles.hasByName('", parstyle, "')"))) {
      pyExec(paste0("scursor.setPropertyValue('ParaStyleName', '", parstyle, "')"))
    } else {
      if (warn) warning("Paragraph Style ", parstyle, " is not available in the document")
    }
}

Try the rlo package in your browser

Any scripts or data that you put into this service are public.

rlo documentation built on May 1, 2019, 10:22 p.m.