CitectVBA Programming Reference > CitectVBA Function Reference > Declarations > Set

Set

Assigns an OLE Automation object reference to a variable of object type.

Syntax

Set objVarName = CreateObject(objClassName) | Nothing

objVarName:

The required name of the variable receiving the reference.

objClassName:

The required class name of the object to be created.

Use the Nothing keyword to release the object reference.

The object variable objVarName must be declared before it can be set to reference an OLE Automation object.

Related Functions

CreateObject | Nothing

Example

' create variable to store object reference
Dim objWord as Object
' create object and assign reference to variable
Set objWord = CreateObject( "Word.Document" )
' insert appropriate VBA code here to manipulate Word object
' release reference
Set objWord = Nothing