Siebel eScript Language Reference > Methods Reference > Global Methods >

Create COM Object Method


The Create COM Object method instantiates a COM object. It returns a successful COM object or an undefined object.

Format

COMCreateObject(objectName)

Table 82 describes the arguments for the Create COM Object method.

Table 82. Arguments for the Create COM Object Method
Argument
Description

objectName

The name of the object that this method creates.

Usage

You can configure Siebel CRM to pass any type of variable to the COM object that it calls. You must make sure the variable type is valid for the COM object. The following variable types are valid:

  • String
  • Number
  • Object pointer

Siebel CRM can run the Create COM Object method only in server script. It cannot run this method in browser script.

A DLL that the Create COM Object method instantiates must be thread-safe.

Using the Dispatch Identifier to Call a COM Method

Siebel CRM calls the method of a COM object in Siebel eScript in the same way that it calls this method in Siebel VB. In this context, a COM object is an object that the Create COM Object method instantiates.

To use the DISPID (Dispatch Identifier) of a COM method to call that COM method, you make an IDispatch::Invoke call in the COM technology. To identify methods, properties, and arguments, you use the Dispatch Identifier in the IDispatch::Invoke call.

You can write code that uses only the following arguments:

  • BSTR (basic string). An eScript string.
  • VARIANT. A universal data type.
  • SAFEARRAY. Similar to a typical C array, but also includes information about the number of elements in the array.

You cannot use Siebel eScript to call the method of a COM object that includes the LPCSTR argument for the string argument of that method. In this situation, you must use the BSTR argument.

Example

The following 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);

An application, such as Microsoft Excel, might change from version to version, so it might be necessary for you to modify your code to address these modifications. This example code was tested on Excel 2003.

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.