getActiveXObject Function

Applies to TestComplete 15.45, last modified on December 01, 2022

Description

In JavaScript, use the getActiveXObject function to get a reference to an OLE object by its name and the name of the machine where it is running. To specify the OLE server running on a local machine, do not specify the MachineName parameter.

Declaration

getActiveXObject(OleObjectMachineName) Parameters
OleObject [in] Required String
MachineName [in] Optional String
Result     Object  

Parameters

ObjectName

ProgID or CLSID of the OLE server you want to access. For example, "Word.Application" or "{000209FF-0000-0000-C000-000000000046}".

MachineName

Specifies the name of the machine where the specified OLE server is running. To get the OLE server running on a local machine, leave the value of this parameter empty.

Result

An object that represents the specified OLE server.

Remarks

  • If, in your code, you have many (more than several hundred) calls to properties and methods of the received object, you may experience performance issues. In this case, we recommend that you do not call properties and methods of the object directly. Use the $get, $set and $call methods for this purpose. This will allow the script to run faster and will improve the performance significantly.

    However, if you have only a few calls to object properties and methods, and you do not face any performance issues, you can keep the usual object-name.method-name syntax. This way your code will be easier to read and maintain.

  • You cannot use TestComplete as a client application for in-process OLE objects, the bitness of which is different than the bitness of TestComplete.

Example

The code below launches Excel and makes the application visible:

JavaScript

// Launch Excel
var Excel = getActiveXObject("Excel.Application");
// Make it visible
Excel.Visible = true;
...

See Also

OleObject Property
GetRemoteOLEObject Method

Highlight search results