Results 1 to 8 of 8

Thread: Excel Process won't turn off

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2015
    Posts
    6

    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

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

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

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2015
    Posts
    6

    Re: Excel Process won't turn off

    Didn't work.

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

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

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    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?

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Excel Process won't turn off

    Smells like VB.Net, not real VB.

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

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

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Excel Process won't turn off

    Quote Originally Posted by dilettante View Post
    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
  •  



Click Here to Expand Forum to Full Width