Ask a Question

Excel.Exe process crashed

nimishbhuta
Frequent Contributor

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 3
Marsha_R
Community Hero

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.


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
AlexKaras
Community Hero

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

 

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

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
shankar_r
Community Hero

It is not objExcel.Application.Quit.

 

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


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

cancel
Showing results for 
Search instead for 
Did you mean: