Jump to content
Sign in to follow this  


Recommended Posts



i have been trying this code for invoking event,but not getting success............

Is something wrong in the code?

Code as follows:

Dim $word=ObjCreate("word.application")

WITH $word




Dim $temp=ObjEvent($word,"myfunc_")

Func myfunc_DocumentsAddContent()

Dim $excel=ObjCreate("excel.application")




$excel.ActiveWorkBook.Saved = 1


any help would be appreciable.



Share this post

Link to post
Share on other sites

There is not an event called "DocumentsAddContent" in word. Here is a link that describes all the events that can be triggered. Below is a working example of the "NewDocument" event. Hope this helps.

Opt("WinTitleMatchMode", 4)

$oWord = ObjCreate("word.application")
$oWord.visible = 1
$oWord.Activate ()
$hwnd = WinGetHandle("active")

; Set up an event sink so we can trigger on events
$oEvent = ObjEvent($oWord, "Evt_")

; This will now be captured as an event
$oWord.Documents.Add ()

While WinExists($hwnd)

Func Evt_NewDocument()
    $oWord.Selection.TypeText ("You created a new document.")
EndFunc   ;==>Evt_NewDocument

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.