views:

19

answers:

0

I am working on adding scripting capability to my application. I have largely solved all the issues. Now I can expose my objects to scripts, and the script can handle events from my objects as well. As a step further I wish that the script is able to handle events fired from third party objects, in a way similar to WScript.ConnectObject.

Set objWord = WScript.CreateObject("Word.Application")
WScript.ConnectObject objWord, "objWord_"

objWord.visible = True
blnWordVisible = True

Do While blnWordVisible
WScript.Sleep 500
Loop

Sub objWord_Quit
    blnWordVisible = False
    WScript.Echo "You quit Word."
End Sub

Sub objWord_DocumentChange
    WScript.Echo "You switched documents."
End Sub

The above Script is based on WSH (Windows Scripting Host). My goal is to change WScript to my own object name (such as Session), and the above script can run inside my application. I already tried IActiveScript::AddNamedItem and IActiveScript::GetItemInfo, tney worked perfect on my objects, but not this global variable objWord_.