gypsy Posted April 7, 2008 Share Posted April 7, 2008 I've had this program working in the past with no problems. Now, it seems that WinWaitActive is not working some/most of the time. Program times out at WinWaitActive. Here is a snipet of the code. Is there a better way to write this? Help Appreciated! $oWord = _WordCreate("C:\Documents\Test", 0, 1, 1) If Not WinWait("Test", "Test", 120) Then FileWriteLine($filelog, @error) FileWriteLine($filelog, " Return Code - 0 WinWait() Timeout occurred") Exit EndIf WinActivate("Test", "Test") If Not WinWaitActive("Test", "Test", 120) Then FileWriteLine($filelog, @error) FileWriteLine($filelog, " Return Code - 0 WinWaitActive() Timeout occurred") Exit EndIf $oDoc = _WordDocGetCollection($oWord, 0) ;Write some text _WordDocSaveAs($oDoc, "C:\Documents\Test") If Not WinClose("Test") Then FileWriteLine($filelog, @error) FileWriteLine($filelog, " Return Code - 0 WinClose() Window not found") Exit EndIf Link to comment Share on other sites More sharing options...
herewasplato Posted April 7, 2008 Share Posted April 7, 2008 (edited) This worked for me 100 out of 100 times :-)AutoItSetOption("WinWaitDelay", 1) ;(milliseconds) AutoItSetOption("TrayIconDebug", 1) ;0-off #include <Word.au3> For $i = 1 To 100 $oWord = _WordCreate("Test", 0, 1, 1) WinWait("Test", "Test", 120) WinActivate("Test", "Test") If WinWaitActive("Test", "Test", 120) = 0 Then MsgBox(0, "WinWaitActive", "Timed out on test number " & $i) EndIf Sleep(2000) _WordQuit($oWord) Sleep(2000) NextXp Pro Sp2 - Office 2003 What OS and what Office version are you having this problem with? Edited April 7, 2008 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] 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