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:
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.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
Thanks,
--Rikki




Reply With Quote