COMAccessors {RDCOMClient}R Documentation

COM Object Accesors

Description

These operators provide a more S-like syntax for accessing methods and properties in a dynamic COM object. One calls a COM object method using the $ operator. The values of COM object properties are retrieved and set using [[ and [[<-

Usage

"$.COMIDispatch"(x, name)
"[[.COMIDispatch"(x, i, j, ...)
"[[<-.COMIDispatch"(x, i, value)

Arguments

x the COM object reference in R
name the name of the method
i the name of the property or a numeric value in which case x is assumed to have a method named Item and act as a container. In this case, the i-th element is returned. This is not supported for setting an element (i.e. [[<-)
j ignored
... ignored
value the value to assign to the property.

Value

Setting a property returns NULL.
Invoking a method and getting a property value returns an S object representing the COM value. Primitive COM values are converted to the corresponding S objects. COM objects are returned as COMIDispatch objects.

Author(s)

Duncan Temple Lang (duncan@research.bell-labs.com)

References

http://www.omegahat.org/RDCOMClient http://www.omegahat.org/RDCOMServer http://www.omegahat.org/SWinTypeLibs http://www.omegahat.org/SWinRegistry

See Also

.COM COMCreate

Examples

 e <- COMCreate("Excel.Application")

  # Boolean/Logical
 e[["Visible"]]
  # Setting a value.
 e[["Visible"]] <- TRUE

  # String
 e[["Path"]]
 e[["Version"]]

  # Double
 e[["Width"]]

  # Long
 e[["SheetsInNewWorkbook"]]
 
  # Object
 books <- e[["Workbooks"]]

 books$Add()

  # Use this as a container, so can have integer indices, 1-based.
 books[[1]]
 e[["Workbooks"]][[1]]

## Not run: 
 books$Open("C:\mySheet.xls")
## End(Not run)

 e$CheckSpelling("This is a spell check") # okay
 e$CheckSpelling("This is a spell chck") # error

## Not run: 
 
 e$SaveWorkspace()
## End(Not run)
 e$Quit()

 rm(list= c("e", "books"))
 gc()


[Package RDCOMClient version 0.8-1 Index]