|
-
Apr 28th, 2015, 09:15 AM
#1
Thread Starter
New Member
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
-
Apr 28th, 2015, 09:31 AM
#2
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'.
-
Apr 28th, 2015, 09:35 AM
#3
Thread Starter
New Member
Re: Excel Process won't turn off
-
Apr 28th, 2015, 09:45 AM
#4
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))
-
Apr 28th, 2015, 09:47 AM
#5
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?
-
Apr 28th, 2015, 10:15 AM
#6
Re: Excel Process won't turn off
Smells like VB.Net, not real VB.
-
Apr 28th, 2015, 11:24 AM
#7
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??).
-
Apr 28th, 2015, 02:15 PM
#8
Re: Excel Process won't turn off
 Originally Posted by dilettante
Smells like VB.Net
Agreed... azurdar, what version of VB are you using (we suspect 2002 or later)?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|