Previous PageNext Page

8.4.14 CreateObject Function

Creates and returns a reference to an Automation object. This should be used as a client-side only function. To create a server-side object, use Server.CreateObject. See the Built-in Objects Reference (Chapter 6) for more information.
 

Syntax

CreateObject(servername.typename)

Arguments

servername
The name of the application providing the object.
typename
The type or class of the object to create.

Remarks

Automation servers provide at least one type of object. For example, a word-processing application may provide an application object, a document object, and a toolbar object.
 

Note:

The CreateObject function will not work with the FileSystemObject if EnableParentPaths is False in the Chili!Soft ASP registery. In this case you must use Server. CreateObject("Scripting.FileSystemObject").

To create an Automation object, assign the object returned by CreateObject to an object variable:
 

Dim ExcelSheet

Set ExcelSheet = CreateObject("Excel.Sheet")

This code starts the application creating the object (in this case, a Microsoft Excel spreadsheet). Once an object is created, you refer to it in code using the object variable you defined. In the following example, you access properties and methods of the new object using the object variable, ExcelSheet, and other Excel objects, including the Application object and the Cells collection. For example:
 

' Make Excel visible through the Application object.

ExcelSheet.Application.Visible = True

' Place some text in the first cell of the sheet.

ExcelSheet.Cells(1,1).Value = "This is column A, row 1"

' Save the sheet.

ExcelSheet.SaveAs "C:\DOCS\TEST.XLS"

' Close Excel with the Quit method on the Application object.

ExcelSheet.Application.Quit

' Release the object variable.

Set ExcelSheet = Nothing


Copyright © 2000 Chili!Soft

Previous PageTop Of PageNext Page