Siebel VB Language Reference > Methods Reference for Siebel VB > COM Methods >

Get COM Object Method


The Get COM Object method returns the COM object that the pathname argument or the class argument identifies. To assign a variable to an object for use in a Visual Basic procedure, you dimension a variable as an object, and then use the Get COM Object method with the Assign COM Object statement.

The examples in this topic reference the SiebelAppServer object, which you define as an object type in your external Visual Basic environment.

Format A

GetObject(pathname)

Format B

GetObject(pathname, class)

Format C

GetObject(, class)

Arguments

The following table describes the arguments that you can use with this method.

Argument
Description

pathname

The full path and file name for the object to get.

class

A string that contains the class of the object.

Usage for Format A

You can use format A to access a COM object that is stored in a file. For example, the following code dimensions a variable as an object and assigns the payables.xls object to this variable. The Payables.xls file is located in the My Documents directory:

Dim oFileObject As Object
Set oFileObject
= GetObject("C:\My Documents\payables.xls")

If the Siebel application supports accessing component objects in the file, then you can append an exclamation point and a component object name to the file name. For example:

Dim oComponentObject As Object
Set o
ComponentObject = _
  GetObject("C:\My Documents\payables.xls!R1C1: R13C9")

Usage for Format B

You can use format B to access a COM object of a particular class that is stored in a file. The class argument uses the following format:

appName.objectType

where:

  • appName is the name of the application that provides the object
  • objectType is the type or class of the object

For example:

Dim oClassObject As Object
Set oClassObject
= GetObject("C:\My _
  Documents\payables.xls", "Excel.Sheet")

Usage for Format C

You can use format C to access the active COM object of a particular class. For example:

Dim oApplication As _
  SiebelHTMLApplication
Set oApplication = _
  GetObject(,"SiebelHTML.SiebelHTMLApplication.1")

If you use format C with a null string ("") in the pathname argument, then Siebel VB returns a new object instance of the class that you specify in the class argument. The preceding example gets an open instance of the Siebel application. The following example instantiates the Siebel application in memory, independent of the user interface:

Set oApplication = _
  GetObject("","SiebelHTML.SiebelHTMLApplication.1")

Example

The following example opens an Excel worksheet and places the contents of the Name field of the active business component in this worksheet. The worksheet file must already exist:

Sub Button1_Click
   Dim ExcelSheet As Object
   Set ExcelSheet = GetObject("C:\demo\test.xls")

   'Make Excel visible through the Application object.
   ExcelSheet.Application.Visible = 1

   'Place some text in the first cell of the sheet.
   ExcelSheet.ActiveSheet.Cells(1, 1).Value = _
      theApplication.ActiveBusComp.GetFieldValue("Name")

   'Save the sheet.
   ExcelSheet.Save
   'Close Excel with the Quit method on the Application object.
      +ExcelSheet.Application.Quit
End Sub

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