APGen Documentation Previous Topic: Script.Abort() Next Topic: Script.ConnectEvents() Parent Topic: Script Object    Script Object
Script.CreateObject()
See Also:

The Script.CreateObject() method creates a COM object, and optionally activates script handling of its events.

Syntax

VBScript:

Set objObject = Script.CreateObject( strProgID, [strHandlerPrefix] )

JScript:

objObject = Script.CreateObject( strProgID, [strHandlerPrefix] );

Object

Script The Script object.

Parameters

strProgID The PROGID of the component being created.
strHandlerPrefix Optional. If supplied, script functions named strHandlerPrefix + EventName are called when this object fires events.

Return Value

objObject The created COM object.

Notes

The CreateObject() method creates a COM object specified by the strProgID parameter. If the parameter strHandlerPrefix is specified, APGen connects to the object's default event interface after creating the object.  When the object fires an event, APGen calls a script subroutine named strHandlerPrefix plus the event name.

For example, if strHandlerPrefix is "Conn1_" and the object fires an event named "OnConnect", APGen calls the "Conn1_OnConnect" subroutine if one can be found in the script.

Script event handling for an object can be disabled by calling Script.DisconnectEvents() and passing in the object.

For more information on handling COM events, see the Sinking COM Events topic.

Example

This example uses Script.CreateObject() to create an APGen object and run another APG script.

...
Dim oAPGen, oScript
Set oAPGen = Script.CreateObject("APGen")
oAPGen.Run("Script.apg")
...

Applies To

Script Object