ManojK Posted October 23, 2018 Author Posted October 23, 2018 i am posting my entire function. please find the same. Func ReadExcelFile() if ProcessExists ("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") EndIf $oExcel = _Excel_Open(False, False, False, True, False) If Not IsObj($oExcel) Then writeToFile($ExecutionLog,"Opening Excel Object in Object checking block" & _NowDate() &" "& _NowTime(5)&@CRLF) $oExcel = _Excel_Open(False, False, False, True, False) ElseIf IsObj($oExcel) Then writeToFile($ExecutionLog,"ExcelObject is Exist" & _NowDate() &" "& _NowTime(5)&@CRLF) Else writeToFile($ExecutionLog,"ElseBlockGotExecutedwhileValidatingExcelObject" & _NowDate() &" "& _NowTime(5)&@CRLF) EndIf writeToFile($ExecutionLog,"Opening ExcelWorkBook:"&$TestDataDirectory & _NowDate() &" "& _NowTime(5)&@CRLF) sleep(2000) $oWorkbook = _Excel_BookOpen($oExcel, $TestDataDirectory,True,False) If @error Then Exit Msgbox(16, "Error!", "Error opening Workbook. @error=" & @error & ", @extended=" & @extended) If @error Then writeToFile($ExecutionLog,"ErrorBlockofOpenWorkBook"& _NowDate() &" "& _NowTime(5)&@CRLF) EndIf sleep(2000) writeToFile($ExecutionLog,"Opened ExcelWorkBook:"&$TestDataDirectory & _NowDate() &" "& _NowTime(5)&@CRLF) writeToFile($ExecutionLog,"Opening ExcelWorkSheet:"&$arrTestCaseFilePath[2]& _NowDate() &" "& _NowTime(5)&@CRLF) $aResult = _Excel_RangeRead($oWorkbook, $arrTestCaseFilePath[2], Default,1,default) If @error Then Local $content = "Failed to open proper Work sheet "&$arrTestCaseFilePath[2] & @CRLF writeToFile($pOutPutLog,$content) exitAutoExecution() EndIf sleep(2000) _Excel_BookClose($oWorkbook, False) _Excel_Close($oExcel,False,True) EndFunc
Juvigy Posted October 23, 2018 Posted October 23, 2018 Wow, this is not good coding at all. Here is what the above code should look like (untested). Try that and tell us the result Func ReadExcelFile() if ProcessExists ("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") EndIf For $a=0 to 5 step 1 $oExcel = _Excel_Open(False, False, False, True, False) If IsObj($oExcel) Then writeToFile($ExecutionLog,"Opening Excel Object in Object checking block" & _NowDate() &" "& _NowTime(5)&@CRLF) Exitloop Endif writeToFile($ExecutionLog,"Failed Opening Excel Object in Object checking block" & _NowDate() &" "& _NowTime(5)&@CRLF) sleep(2000) Next $oWorkbook = _Excel_BookOpen($oExcel, $TestDataDirectory,True,False) If @error Then writeToFile($ExecutionLog,"ErrorBlockofOpenWorkBook"& _NowDate() &" "& _NowTime(5)&@CRLF) Exit EndIf sleep(2000) $aResult = _Excel_RangeRead($oWorkbook, $arrTestCaseFilePath[2], Default,1,default) If @error Then writeToFile($pOutPutLog,"Failed to open proper Work sheet "&$arrTestCaseFilePath[2] & @CRLF) _Excel_BookClose($oWorkbook, False) _Excel_Close($oExcel,False,True) EndFunc
ManojK Posted October 24, 2018 Author Posted October 24, 2018 Hi Juvigy, Again we encountered same error after code update as per above suggestion. Please find the below screenshot. Screenshot i captured Task Manager, Our Error and User Log file.
ManojK Posted October 24, 2018 Author Posted October 24, 2018 On 9/29/2018 at 12:13 AM, jdelaney said: Just as a pure debugging exercise, you can convert and run your script as a vbs script. I'd also google the com method and see what the Microsoft community has to say about it. tldr: sounds like a Microsoft problem and not an autoit problem How to convert AutoIT script to VB- script and does AutoIt supports VBScript? after reading from excel we are performing few operations on Putty application using AutoIT. If we convert as VBS does it support putty application as well?
Juvigy Posted October 24, 2018 Posted October 24, 2018 This looks like compiled error. On which line of the function that i provided do you see the error? PS. Autoit could call vbs script and vbs scripts could be converted in AutoIt.
ManojK Posted October 24, 2018 Author Posted October 24, 2018 While executing below step we are facing issue. $oWorkbook = _Excel_BookOpen($oExcel, $TestDataDirectory,True,False) would it be possible to provide any reference how to use VBscript in AutoIT Tool
Juvigy Posted October 29, 2018 Posted October 29, 2018 Then try this: Func ReadExcelFile() if ProcessExists ("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") EndIf For $a=0 to 5 step 1 $oExcel = _Excel_Open(False, False, False, True, False) If IsObj($oExcel) Then writeToFile($ExecutionLog,"Opening Excel Object in Object checking block" & _NowDate() &" "& _NowTime(5)&@CRLF) $oWorkbook = _Excel_BookOpen($oExcel, $TestDataDirectory,True,False) If @error Then writeToFile($ExecutionLog,"ErrorBlockofOpenWorkBook"& _NowDate() &" "& _NowTime(5)&@CRLF) Exit Endif Exitloop Endif writeToFile($ExecutionLog,"Failed Opening Excel Object in Object checking block" & _NowDate() &" "& _NowTime(5)&@CRLF) sleep(2000) Next $aResult = _Excel_RangeRead($oWorkbook, $arrTestCaseFilePath[2], Default,1,default) If @error Then writeToFile($pOutPutLog,"Failed to open proper Work sheet "&$arrTestCaseFilePath[2] & @CRLF) _Excel_BookClose($oWorkbook, False) _Excel_Close($oExcel,False,True) EndFunc
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