CreateObject Method (Scripting Object)

Object: Scripting Object

Create and return a reference to an Automation Object. If the new object has an associated type library, the method automatically adds the type library to the script.

Usage

Scripting.CreateObject (ByVal Class As String, [ByVal EventPrefix As Variant]) As Object

Arguments

Class

ProgID in the form Servername.Typename that specifies the object to create. For more information about the program IDs, see Program IDs for Applications and Automation Engines.

EventPrefix

(Optional) Optional argument used to bind to the outgoing interface of the object. If specified, the script engine connects the object's outgoing interface to the script file after creating the object. When the object fires an event, the script engine calls a subroutine named EventPrefix and the event name. For example, if EventPrefix is “MyObj” and the object fires an event named “OnBegin,” The scripting engine calls the “MyObj_OnBegin” subroutine located in the script. The underscore is automatically added between then EventPrefix and the Event name.

Return Values

String naming the newly created object.

Examples

' Create a PADS Layout application object 
Dim appPCB 
Set appPCB = Scripting.CreateObject("PowerPCB.Application.78")