Siebel eScript Language Reference > Siebel eScript Commands > Conversion or Casting Methods >

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. Can only executed in server script, this 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.

See Also

CORBACreateObject() Method

Siebel eScript Language Reference