RDCOMClient: how to use enum objects or how to get their match values?

The package RDCOMclient

can be used to connect to COM objects on Windows. There are many enums in the MSDN link (e.g. wdColorBlue

for blue, see here ) that match the meaning. They can be directly used in, for example, VBA code.

How can I work with enum objects using RDCOMClient? Is there, for example, a way to get the corresponding value for an enum from R? There is a function EnumValue

, but I don't see how to use it for this purpose.

A small example

The following codes create a new Word document and write some text into it. The paragraph has been changed to right justification. An integer is used here 2

, which corresponds to the numbering wdAlignParagraphRight

. I would like to be able to use, for example, a string "wdAlignParagraphRight"

instead of a value 2

. Is there a way to do this using RDCOMclient


x <- COMCreate("Word.Application")            # create application
x[["visible"]] <- TRUE
p <- x[["ActiveDocument"]][["Paragraphs"]]$Item(1)  
p[["Alignment"]] <- 2



source to share

All Articles