The RDCOMclient
package can be used to connect to COM objects on Windows. In the MSDN reference many enumerations exist (e.g. wdColorBlue
for blue, see here) which correspond to a value. These can be directly used e.g. in VBA code.
How can I work with enumeration objects using RDCOMClient? Is there e.g. a way to retrieve the corresponding value for an enumeration from within R? There is a function EnumValue
but I do not see how to use it for this purpose.
A small example
The following codes creates a new Word document and writes some text in it. The paragraph is changed to right alignment. Here the integer 2
is used which corresponds to the enumeration wdAlignParagraphRight
. I would like to be able to use e.g. the string "wdAlignParagraphRight"
instead of the value 2
. Is there a way to do that using RDCOMclient
?
x <- COMCreate("Word.Application") # create application
x[["visible"]] <- TRUE
x[["Documents"]]$Add()
x[["Selection"]]$TypeText("hello")
p <- x[["ActiveDocument"]][["Paragraphs"]]$Item(1)
p[["Alignment"]] <- 2