Jump to content

.exe has stopped working error message


ManojK
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

 

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...