neotrio Posted July 31, 2006 Share Posted July 31, 2006 hi, 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 .visible=1 .Documents.Add.Content="hello" ENDWITH Dim $temp=ObjEvent($word,"myfunc_") Func myfunc_DocumentsAddContent() Dim $excel=ObjCreate("excel.application") $excel.visible=1 $excel.WorkBooks.Add $excel.ActiveWorkBook.ActiveSheet.Cells(1,1).Value="hekllo" $excel.ActiveWorkBook.Saved = 1 EndFuncany help would be appreciable.Regards,Neotrio Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 31, 2006 Moderators Share Posted July 31, 2006 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) Sleep(10) WEnd Func Evt_NewDocument() $oWord.Selection.TypeText ("You created a new document.") EndFunc ;==>Evt_NewDocument Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now