Siebel eScript Language Reference > Siebel eScript Commands > Global Objects >

COMCreateObject() Method


COMCreateObject instantiates a COM object.

Syntax

COMCreateObject(objectName)

Parameter
Description

objectName

The name of the object to be created

Returns

A COM object if successful; otherwise, undefined.

Usage

You should be able to pass any type of variable to the COM object being called; however, you must ascertain that the variable is of a valid type for the COM object. Valid types are strings, numbers, and object pointers. This method can be executed in server script only; it does not apply to browser script.

NOTE:  DLLs instantiated by this method must be thread-safe.

Example

This example instantiates Microsoft Excel as a COM object and makes it visible:

var ExcelApp = COMCreateObject("Excel.Application");

// Make Excel visible through the Application object.
ExcelApp.Visible = true;
ExcelApp.WorkBooks.Add();

// Place some text in the first cell of the sheet
ExcelApp.ActiveSheet.Cells(1,1).Value = "Column A, Row 1";

// Save the sheet
var fileName = "C:\\demo.xls";
ExcelApp.ActiveWorkbook.SaveAs (fileName);

// Close Excel with the Quit method on the Application object
ExcelApp.Application.Quit();

// Clear the object from memory
ExcelApp = null;
return (CancelOperation);

NOTE:  Applications, such as Excel, may change from version to version, requiring you to change your code to match. This example code was tested on Excel 2002.

Siebel eScript Language Reference Copyright © 2007, Oracle. All rights reserved.