Excel Process won't turn off
After I run my code, the Excel process in the Task Manager will not go away. Here is the code:
Sub SavePartNumbersInSession()
Dim ExcelObj As Object
Dim i As Integer
Dim j As Integer
ExcelObj = CreateObject("Excel.Application")
ExcelObj.WorkBooks.Open(sPath + System.IO.Path.GetFileName(MyFile.PostedFile.FileName))
i = 1
j = 2
Session("PartNumbers") = ""
Do Until ExcelObj.Workbooks(1).WorkSheets(1).cells(1, i).value & "" = ""
If ExcelObj.Workbooks(1).WorkSheets(1).cells(1, i).value = "Part Number" Then
ExcelObj.Workbooks(1).WorkSheets(1).UsedRange.Columns(i).NumberFormat = "@"
Do Until ExcelObj.Workbooks(1).WorkSheets(1).cells(j, i).value & "" = ""
If IsNumeric(ExcelObj.Workbooks(1).WorkSheets(1).cells(j, i).value) Then
If Session("PartNumbers") <> "" Then
Session("PartNumbers") &= "|"
End If
Session("PartNumbers") &= CStr(ExcelObj.Workbooks(1).WorkSheets(1).cells(j, i).value)
End If
j = j + 1
Loop
End If
i = i + 1
Loop
ExcelObj.DisplayAlerts = False
ExcelObj.Workbooks(1).Close()
ExcelObj.Quit()
ExcelObj = Nothing
End Sub
Re: Excel Process won't turn off
try "Set ExcelObj = Nothing"
I don't see any reason (other than that possibly) why it is not 'quitting'.
Re: Excel Process won't turn off
Re: Excel Process won't turn off
Run it with debugger and make sure it is getting to your 'nothing' line.
(also, minor note....use "&" in lieu of "+" when concatenating strings---ExcelObj.WorkBooks.Open(sPath + System.IO.Path.GetFileName(MyFile.PostedFile.FileName))
Re: Excel Process won't turn off
Session("PartNumbers") &= "|" ---what is this? What the ampersand supposed to do?
Session("PartNumbers") &= CStr(ExcelObj.Workbooks(1).WorkSheets(1).cells(j, i).value) ---and this?
Do you have On Error Resume Next somewhere which will bypass your errors?
Re: Excel Process won't turn off
Smells like VB.Net, not real VB.
Re: Excel Process won't turn off
Oh how true...wasn't paying attention. But still, sounds like some code is not getting run for some reason (OERN??).
Re: Excel Process won't turn off
Quote:
Originally Posted by
dilettante
Smells like VB.Net
Agreed... azurdar, what version of VB are you using (we suspect 2002 or later)?