Siebel VB Language Reference > VB Language Reference >
GetObject Function
This standard VB function returns a COM object associated with the file name or the application name. Syntax A
GetObject(pathname) Syntax B
GetObject(pathname, class) Syntax C
GetObject(, class)
|
|
pathname |
The full path and filename for the object to retrieve |
class |
A string containing the class of the object |
Returns
The object associated with pathname or the object associated with class. Usage
Use GetObject with the Set statement to assign a variable to the object for use in a Basic procedure. The variable used must first be dimensioned as an object. Syntax A of GetObject accesses a COM object stored in a file. For example, the following two lines dimension a variable as an object and assign the object payables.xls to it. Payables.xls is located in the My Documents folder : Dim oFileObject As Object Set oFileObject = GetObject("C:\My Documents\payables.xls")
If the application supports accessing component objects within the file, you can append an exclamation point and a component object name to the file name, as follows: Dim o ComponentObject As Object Set o ComponentObject = _ GetObject("C:\My Documents\payables.xls!R1C1: R13C9")
Syntax B of GetObject accesses a COM object of a particular class that is stored in a file. Class uses the syntax appName.objectType, where appName is the name of the application that provides the object, and 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")
The third form of GetObject accesses the active COM object of a particular class. For example: Dim oApplication As _ SiebelHTMLApplication Set oApplication = _ GetObject(,"SiebelHTML.SiebelHTMLApplication.1")
If you use the third form of GetObject with a null string ("") as the pathname, a new object instance of the specified type is returned. Thus, the preceding example gets an open instance of the Siebel application, while Set oApplication = _ GetObject("","SiebelHTML.SiebelHTMLApplication.1")
instantiates the Siebel application in memory, independent of the user interface. NOTE: The last two examples refer to the object SiebelAppServer, which has been defined as an object type as configured in your external Visual Basic environment.
Example
This example opens a specific Excel worksheet and places the contents of the Name field of the active business component in it. 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
Related Topics
CreateObject Function Is Operator Me Object New Operator Nothing Function Object Class Typeof Function
|