Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Excel file does not close in task manager

Excel file does not close in task manager

Scheduled Pinned Locked Moved Visual Basic
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anoop Brijmohun
    wrote on last edited by
    #1

    hi guys, The code below works fine except when i open the windows task manager, i can still see EXCEL.EXE Running. how do i close or exit it, should not objFso.Quit() Close Excel? thanks

    Dim objFSO, ObjWb, ObjWs As New Object

    objFSO = CreateObject("Excel.Application")
    ObjWb = objFSO.Workbooks.Open("c:\myapp.xls")

    For Each ObjWs In ObjWb.Worksheets
    MsgBox(ObjWs.Name)
    Application.DoEvents()
    Next

    objFso.Quit()

    C R L 3 Replies Last reply
    0
    • A Anoop Brijmohun

      hi guys, The code below works fine except when i open the windows task manager, i can still see EXCEL.EXE Running. how do i close or exit it, should not objFso.Quit() Close Excel? thanks

      Dim objFSO, ObjWb, ObjWs As New Object

      objFSO = CreateObject("Excel.Application")
      ObjWb = objFSO.Workbooks.Open("c:\myapp.xls")

      For Each ObjWs In ObjWb.Worksheets
      MsgBox(ObjWs.Name)
      Application.DoEvents()
      Next

      objFso.Quit()

      C Offline
      C Offline
      ChandraRam
      wrote on last edited by
      #2

      Since you have work books open, it would probably prevent Excel from closing.

      A 1 Reply Last reply
      0
      • C ChandraRam

        Since you have work books open, it would probably prevent Excel from closing.

        A Offline
        A Offline
        Anoop Brijmohun
        wrote on last edited by
        #3

        well this seems to work.... i have added this after the worksheets loop...

        ObjWb.close()
        releaseObject(ObjWs)
        ObjWs = Nothing
        releaseObject(ObjWb)
        ObjWb = Nothing
        releaseObject(objFSO)

                objFSO = Nothing
        
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Critical)
            End Try
        End Sub
        Private Sub releaseObject(ByVal obj As Object)
            Try
                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
                obj = Nothing
            Catch ex As Exception
                obj = Nothing
            Finally
                GC.Collect()
            End Try
        End Sub
        
        1 Reply Last reply
        0
        • A Anoop Brijmohun

          hi guys, The code below works fine except when i open the windows task manager, i can still see EXCEL.EXE Running. how do i close or exit it, should not objFso.Quit() Close Excel? thanks

          Dim objFSO, ObjWb, ObjWs As New Object

          objFSO = CreateObject("Excel.Application")
          ObjWb = objFSO.Workbooks.Open("c:\myapp.xls")

          For Each ObjWs In ObjWb.Worksheets
          MsgBox(ObjWs.Name)
          Application.DoEvents()
          Next

          objFso.Quit()

          R Offline
          R Offline
          Ravi Kumar Tyagi
          wrote on last edited by
          #4

          You also have to dispose the object

          1 Reply Last reply
          0
          • A Anoop Brijmohun

            hi guys, The code below works fine except when i open the windows task manager, i can still see EXCEL.EXE Running. how do i close or exit it, should not objFso.Quit() Close Excel? thanks

            Dim objFSO, ObjWb, ObjWs As New Object

            objFSO = CreateObject("Excel.Application")
            ObjWb = objFSO.Workbooks.Open("c:\myapp.xls")

            For Each ObjWs In ObjWb.Worksheets
            MsgBox(ObjWs.Name)
            Application.DoEvents()
            Next

            objFso.Quit()

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            close the workbook also, excel.workbook.close

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups