COMCreate: Create a COM object

View source: R/com.R

COMCreateR Documentation

Create a COM object

Description

These functions are used from R to either create a COM object of a specific type or to obtain a reference to an existing COM application/object.

Usage

COMCreate(name, ..., existing = TRUE)
getCOMInstance(guid, force = TRUE, silent = FALSE)

Arguments

name

the name identifying the type of COM object. This is usually the name of the class, such as Excel.Application. In the future, this may support finding class IDs separately and passing them as this argument

...

currently ignored. In the future, we will have arguments controlling how the server is created, e.g. the location of the machine, etc.

guid

a string (character vector of length 1) that identifies the GUID - Global Unique Identifier - for the COM interface of interest. This should have the curly braces ('...').

existing

a logical value. If this is TRUE, then first we try to connect to an existing instance of the specified DCOM server, If no such instance exists, then we create a new one. If this is FALSE, then we just create a new instance and don't check whether there is one already running. This guarantees that we get

force

a logical value. If this is TRUE, this will (attempt to) create a new instance of the specified DCOM application if there is no instance already in existence. In other words, getCOMInstance will look for an existing instance and if that fails, it will create a new one. If this is FALSE, getCOMInstance will return after attempting to find an existing instance. As a result, the return value might be NULL.

silent

a logical value that is used when force is TRUE and a new object needs to be created. If this is TRUE, the warning message about creating the new instance is supressed. Otherwise, the warning is issued.

Details

This resolves the class ID given the name and then creates the instance using CoCreateInstance. The class ID is found using CLSIDFromString and if that fails using CLSIDFromProgID.

Value

An object of class COMIDispatch.

Note

getCOMInstance works with Word and Excel but for some reason on at least some machines fails to find an existing Internet Explorer application. As a result, it will create a new instance of the application.

Author(s)

Duncan Temple Lang (duncan@r-project.org)

References

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

See Also

The $ and [[ operators for the COMIDispatch class - COMAccessors.

Also, see how one can generate "compiled" or processed interfaces to any or all of the types in an application using the SWinTypeLibs.

Examples


## Not run: 
 COMCreate("Excel.Application")
 getCOMInstance("{000208D5-0000-0000-C000-000000000046}")

## End(Not run)

omegahat/RDCOMClient documentation built on July 24, 2022, 5:45 a.m.