Results 1 to 3 of 3

Thread: [RESOLVED] [2005] HELP closing application properly

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2008
    Location
    Waterloo, ON
    Posts
    251

    Resolved [RESOLVED] [2005] HELP closing application properly

    I have designed an application in VB which reads information from an Excel file. When the program closes I want to close the connection to and quit excel, delete the excel file it was using, and then close the application. The reason I have put Me.Close() at the end is that before it was leaving the program in memory. Here is my code:

    Code:
    Private Sub AcntBalanceInfo_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
            oExcel.Quit()
            Threading.Thread.Sleep(100)
            My.Computer.FileSystem.DeleteFile("C:\Bank Balance Info.temp.xls")
            Me.Close()
        End Sub
    oExcel.Quit() seems to close the connection or maybe the workbook but not the process. I can then delete the file, but my application won't close because the file is missing. The way I see it, if excel closed properly then there would be nothing to read the file and it wouldn't matter that the file is missing. Does this make sense? Why is oExcel.Quit() not closing Excel properly? Attached is the file.

    Thanks,
    --Rikki
    Last edited by Rikki_UW; Oct 30th, 2008 at 07:55 AM.

  2. #2
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: [2005] HELP closing application properly

    I have an application doing something similar. Have you tried forcing an end to your application to release the Excel objects:

    Code:
    Private Sub AcntBalanceInfo_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
            oExcel.Quit()
            Threading.Thread.Sleep(100)
            My.Computer.FileSystem.DeleteFile("C:\Bank Balance Info.temp.xls")
            Me.Close()
            END
        End Sub
    The application I have, if I do not force a close, the Excel objects remain open until the app is FORCED down.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2008
    Location
    Waterloo, ON
    Posts
    251

    Re: [2005] HELP closing application properly

    Thanks .NetNinja, It works when I replace Me.Close() with End.

    --Rikki

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