Microsoft® Windows® Script Host
ConnectObject Method
WSH Reference
Version 2

Applies To


Description
Connects an object's event sources to functions with a given prefix.
Syntax
object.ConnectObject strObject, strPrefix
Parameters
Part Description
object WScript object.
strObject Name of the object to be connected.
strPrefix Prefix of the event function.
Remarks
The object must be capable of enumerating its own class event set.
Example
The following example instantiates a fictitious object and connects it to the script file. The script then calls the "SomeMethod" method on the object. If an event called "Event" occurs in the object, the MyEvent_Event subroutine is called.
Set MyObject = WScript.CreateObject("SomeObject")
MyObject.SomeMethod
WScript.ConnectObject MyObject, "MyEvent"

Sub MyEvent_Event(strName)
  WScript.Echo strName
End Sub

WScript.DisconnectObject MyObject