CreateObject function (LotusScript® Language)

Creates an OLE Automation object of the specified class.

Note: CreateObject is not supported under UNIX or for HCL Nomad.

Syntax

CreateObject ( className )

Elements

className

A string of the form appName.appClass, designating the kind of object to create (for example, "WordPro.Application").

The appName is an application that supports OLE Automation.

The appClass is the class of the object to create. Products that support OLE Automation provide one or more classes. See the product documentation for details.

Return value

CreateObject returns a reference to an OLE Automation object.

Usage

Use the Set statement to assign the object reference returned by CreateObject to a Variant variable.

If the applicationis not already running, CreateObject starts it before creating the OLE Automation object. References to the object remain valid only while the application is running. If the application terminates while you are using the object reference, LotusScript® raises a run-time error.

LotusScript® supports the OLE vartypes listed in the following table. Only an OLE method or property can return a vartype designated as "OLE only."

OLE vartype

Description

VT_EMPTY

(No data)

VT_NULL

(No data)

VT_I2

2-byte signed integer

VT_I4

4-byte signed integer

VT_R4

4-byte real

VT_R8

8-byte real

VT_CY

Currency

VT_DATE

Date

VT_BSTR

String

VT_DISPATCH

IDispatch, OLE only

VT_ERROR

Error, OLE only

VT_BOOL

Boolean

VT_DECIMAL

Decimal, converted to Double

VT_VARIANT

(A reference to data of any other type)

VT_UNKNOWN

IUnknown, OLE only

VT_ARRAY

(An array of data of any other type)

LotusScript® supports iterating over OLE collections with a ForAll statement.

LotusScript® supports passing arguments to OLE properties. For example:

' Set v.prop to 4; v.prop takes two arguments.
v.prop(arg1, arg2) = 4

LotusScript® does not support identifying arguments for OLE methods or properties by name rather than by the order in which they appear, nor does LotusScript® support using an OLE name by itself (without an explicit property) to identify a default property.

Results are unspecified for arguments to OLE methods and properties of type boolean, byte, and date that are passed by reference. LotusScript® does not support these data types.

The word CreateObject is not a LotusScript® keyword.

Example