Sign in to follow this  
Followers 0
neotrio

ObjEvent?

2 posts in this topic

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

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)
    Sleep(10)
WEnd

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  
Followers 0