Twinlinked Posted July 19, 2011 Share Posted July 19, 2011 WinWait("Microsoft Excel");Excel is being launched elsewhere $oExcel = ObjGet("","EXCEL.Application");Get the excel object if @error then Msgbox (0,"ExcelTest","Error Getting an active Excel Object. Error code: " & hex(@error,8)) exit endif ExcelReady() Func ExcelReady() If $oExcel.Ready = False Then Sleep(5000) ExcelReady() Else ;Msgbox (0,"ExcelTest","GTG") EndIf Return EndFunc I am running the above function to see if excel is ready before my script moves on to the next step, unfortunately if i use ObjGet("","EXCEL.Application")the function runs just fine, however it seems that if this "$oExcel.Ready = False" condition is met then my script has an error: C:\Documents and Settings\buchanan\Desktop\MSR scripts\Work\test2.au3 (14) : ==> The requested action with this object has failed.: If $oExcel.Ready = False Then If $oExcel.Ready ^ ERROR Is there something i am missing to make this function work? All i want to do is have the script pause whenever excel is not ready for the next key stroke in a script. Alternatively is there a macro in excel i could run that would check if excel is ready and then tell auto it to move on? thanks for the help A. Link to comment Share on other sites More sharing options...
GMK Posted July 19, 2011 Share Posted July 19, 2011 I've never needed to wait for Excel to be ready, but a much easier way would be: While Not $oExcel.Ready Sleep(250) WEnd WinWait("Microsoft Excel");Excel is being launched elsewhere $oExcel = ObjGet("","EXCEL.Application");Get the excel object if @error then Msgbox (0,"ExcelTest","Error Getting an active Excel Object. Error code: " & hex(@error,8)) exit endif ExcelReady() Func ExcelReady() If $oExcel.Ready = False Then Sleep(5000) ExcelReady() Else ;Msgbox (0,"ExcelTest","GTG") EndIf Return EndFunc I am running the above function to see if excel is ready before my script moves on to the next step, unfortunately if i use ObjGet("","EXCEL.Application")the function runs just fine, however it seems that if this "$oExcel.Ready = False" condition is met then my script has an error: C:\Documents and Settings\buchanan\Desktop\MSR scripts\Work\test2.au3 (14) : ==> The requested action with this object has failed.: If $oExcel.Ready = False Then If $oExcel.Ready ^ ERROR Is there something i am missing to make this function work? All i want to do is have the script pause whenever excel is not ready for the next key stroke in a script. Alternatively is there a macro in excel i could run that would check if excel is ready and then tell auto it to move on? thanks for the help A. Link to comment Share on other sites More sharing options...
Twinlinked Posted July 19, 2011 Author Share Posted July 19, 2011 (edited) WinWait("Microsoft Excel");Excel is being launched elsewhere $oExcel = ObjGet("","EXCEL.Application");Get the excel object if @error then Msgbox (0,"ExcelTest","Error Getting an active Excel Object. Error code: " & hex(@error,8)) exit endif ExcelReady() func excelready() While Not $oExcel.Ready Sleep(250) WEnd endfunc would above be the correct code for this function? how do i confirm that it is in fact checking to make sure excel is ready? Thanks Edited July 19, 2011 by Twinlinked Link to comment Share on other sites More sharing options...
Twinlinked Posted July 19, 2011 Author Share Posted July 19, 2011 WinWait("Microsoft Excel");Excel is being launched elsewhere $oExcel = ObjGet("","EXCEL.Application");Get the excel object if @error then Msgbox (0,"ExcelTest","Error Getting an active Excel Object. Error code: " & hex(@error,8)) exit endif ExcelReady() func excelready() While Not $oExcel.Ready Sleep(250) WEnd endfunc would above be the correct code for this function? how do i confirm that it is in fact checking to make sure excel is ready? Thanks I am still getting an error from this line: While Not $oExcel.Ready is it possible that this "$oExcel.Ready" statement is incorrect, it seems to work part of the time.. A. Link to comment Share on other sites More sharing options...
GMK Posted July 19, 2011 Share Posted July 19, 2011 Yes, that would be the correct syntax. Basically, it's just sleeping until $oExcel.Ready = True. If you're getting an error with $oExcel.Ready, perhaps there's a problem with the $oExcel object. You might try testing using the IsObj function instead of (or in addition to) @error.I am still getting an error from this line: While Not $oExcel.Readyis it possible that this "$oExcel.Ready" statement is incorrect, it seems to work part of the time..A. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 20, 2011 Share Posted July 20, 2011 I couldn't find a combination that failed on $oExcel.Ready or with IsObj(). But I did fail to get ObjName($oExcel) until I explicitly disabled 64-bit (32-bit MS Office 2010 on Win7Pro 64-bit): #AutoIt3Wrapper_UseX64=N ; Don't use 64-bit #include <Excel.au3> HotKeySet("{ESC}", "_Quit") ; Always have a way to quit $oExcel = _ExcelBookNew() ; Get the excel object If Not @error Then ConsoleWrite("Succeeded in getting active Excel application object, Type = " & VarGetType($oExcel) & @LF) For $n = 1 To 7 ConsoleWrite(@TAB & $n & ": Name = " & ObjName($oExcel, $n) & @LF) ; Only type 1 responds with "_Application" Next Else MsgBox(0, "ExcelTest", "Error Getting an active Excel Object. Error code: 0x" & Hex(@error, 8)) Exit EndIf ExcelReady() Func excelready() While Not $oExcel.Ready ConsoleWrite("Not ready..." & @LF) Sleep(1000) WEnd ConsoleWrite("Ready!" & @LF) EndFunc ;==>excelready Func _Quit() Exit EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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