Forum Discussion

nimishbhuta's avatar
nimishbhuta
Frequent Contributor
7 years ago

Excel.Exe process crashed

Hello All, 

 

I am facing an issue where I am getting this error message that Excel.Exe process crashed in the log message. The thing is I am able to continue with it but it shows an error in log message. 

 

below is the function I am using to create an excel file 

 

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = FALSE
objExcel.DisplayAlerts = FALSE
Set objWorkbook = objExcel.Workbooks.Open(var_ReportFileLocation)
Set objWorksheet = objWorkbook.Worksheets(2)
For iCounter = 0 To oReportDict.Count-1 Step 1
intkeyno=Me.func_GetKeyUsingIndex(iCounter)
arrIndexValue=Split(Me.func_GetItem(intkeyno),";")
objWorksheet.cells(intkeyno,1) =arrIndexValue(0)
objWorksheet.cells(intkeyno,2) =arrIndexValue(1)
objWorksheet.cells(intkeyno,3) =arrIndexValue(2)
objWorksheet.cells(intkeyno,4) =arrIndexValue(3)
'objWorksheet.cells(intkeyno,5) =arrIndexValue(4)
'objWorksheet.cells(intkeyno,6) =arrIndexValue(5)


If lcase(arrIndexValue(3)) = "pass" Then
objWorksheet.cells(intkeyno,4).Interior.ColorIndex = 4
ElseIf lcase(arrIndexValue(3)) = "fail" Then
'strgSummaryStatus=strgSummaryStatus&";"&arrIndexValue(3)
objWorksheet.cells(intkeyno,4).Interior.ColorIndex = 3
End If

If lcase(arrIndexValue(4))="true" Then
objWorksheet.Hyperlinks.Add objWorksheet.cells(intkeyno,5),arrIndexValue(6),,,"Click for ScreenShot"
End if


Next
objWorkbook.Save
set objWorksheet = nothing
set objWorkbook = nothing
objExcel.Application.Quit
set objExcel = nothing

 

 

The issue happens as soon excel application is quit, if I remove Excel.Application.Quit then it does not show me an error. I am using .xls file, I tried with .xlsx also but same error. 

 

Any idea on this ?

 

Regards,

 

Nimish

 

3 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    It is not objExcel.Application.Quit.

     

    It is just objExcel.Quit as you are already in the Application instance.

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    I would try making objExcel.Visible true and watching it run.  Perhaps there's an error or some other conflict that you can see happening.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Nimish,

     

    Another two quick ideas to consider:

    a)

    > Set objExcel = CreateObject("Excel.Application")

    (Depending on the OS?) This line will create a new instance of Excel but not to connect to the already running Excel instance if any. However, Excel is a single-instance application and it is not a good idea to create more than one instance of it. If you need to connect to the already running instance of Excel, you may use the approach described here: https://smartbear-cc.force.com/portal/KbArticleViewer?name=Get-COM-reference-for-a-running-Excel-instance&sp=testcomplete

     

    b)

    > objExcel.Application.Quit

    It may take Excel some time to close. Does it help if you wait for some time to let Excel quit before setting the reference to it to Nothing? (BTW, somewhere in time it was an article that discussed the necessity of setting object variables to Nothing in VBScript.)

    Something like this:

    Call objExcel.Application.Quit()

    Call objExcel.WaitProperty("Exists", False, 60000)

    If (objExcel.Exists) Then

      Call objExcel.SaveDumpToLog()

      Call objExcel.Terminate()

    End If
    Set objExcel = Nothing