|
-
Oct 29th, 2008, 01:08 PM
#1
Thread Starter
Addicted Member
[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.
-
Oct 29th, 2008, 01:29 PM
#2
Hyperactive Member
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.
-
Oct 29th, 2008, 02:00 PM
#3
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|