Jump to content

ObjEvent?


Recommended Posts

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

EndFunc

any help would be appreciable.

Regards,

Neotrio

Link to comment
Share on other sites

  • Moderators

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...