AttachEvents Method (Scripting Object)

Object: Scripting Object

Attaches an object's event sources to script functions with a given prefix.

Usage

Scripting.AttachEvents (ByVal Object As Object, ByVal ObjectName As String) As Boolean

Arguments

Object

The object that you want to attach to.

ObjectName

Prefix string used to map the object events for this instance. When the object fires an event named Foo, the script engine calls a subroutine named EventPrefix_Foo.

Return Values

Boolean indicating of the method succeeded (True) or failed (False).

Examples

' Attach application object to its event handlers with prefix appEvents 
Dim app 
Set app = GetObject(, "MGCPCB.Application") 
Call Scripting.AttachEvents(app, "appEvents")