CitectVBA Programming Reference > Understanding CitectVBA Language Basics > OLE Services > Declaration of OLE automation objects

Declaration of OLE automation objects

CitectVBA objects can only be declared and referenced within CitectVBA file modules. CitectVBA modular objects have modular scope and cannot be referenced (accessed and used) from outside their CitectVBA module (file).

Note: CitectVBA objects cannot be used directly in CitectSCADA command or expression fields.

Once declared within a CitectVBA module, CitectVBA objects can be referenced and used in any procedure within the same code module. An object declared outside of a procedure has modular scope to all procedures within that same CitectVBA module (file). Objects declared within a Sub or Function procedure have local scope only within that procedure.

The object variable must be declared before it can be assigned an object reference. Object variables are declared by the Dim Statement with the As Object CitectVBA data type using the following syntax:

Dim <VariableName> As Object


For example:

' create local variables to store object references
Dim objExcelApp As Object
Dim objWordApp As Object

Once declared, you can then assign an OLE Automation reference to the object variable in CitectVBA.

See Also

Deleting OLE automation objects

Using OLE automation objects