Siebel eScript Language Reference > Siebel eScript Commands > The Global Object >

COMCreateObject() Method

COMCreateObject instantiates a COM object.





The name of the object to be created


A COM object if successful; otherwise, undefined.


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.


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;

// 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

// 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