PDA

View Full Version : closing excel application



Yvaine
07-05-2008, 06:20 AM
I have a coding in microsoft access to open an excel file. After i close the application, the EXCEL.EXE still appear in the task manager under process. How could i do it? i attache with my coding below:-

Dim App As Excel.Application
Dim WkBk As Excel.Workbook
Set App = CreateObject("Excel.Application")
strCollateral = Trim(dhFileDialog(strInitDir:=C_INAppPath, strFilter:=" All Files(*.*)", strFileName:=" ", strDialogTitle:="Please choose the file"))
On Error GoTo HandleErrors
Set WkBk = Excel.Application.Workbooks.Open(FileName:=strCollateral)
WkBk.Close (False)
App.Quit
Set App = Nothing
'If Not (ExcelApp Is Nothing) Then ExcelApp.Quit
HandleErrors:
Dim intResponse As Integer
Select Case Err.Number
Case 53, 76
intResponse = MsgBox("File or path not found")
Case 71
intResponse = MsgBox("Disk not ready. Retry?")
Case Else
intResponse = MsgBox(Err.Number & " " & Err.Description)
End Select

Norie
07-05-2008, 08:18 AM
Why are you using Excel instead of App here?

Set WkBk = Excel.Application.Workbooks.Open(FileName:=strCollateral)

Yvaine
07-05-2008, 10:30 PM
I have changed to use App and also set workbook to nothing after closing the workbook and before closing the application but still the same.

Yvaine
07-05-2008, 11:53 PM
Added on July 6, 2008, 2:49 pmI found something. The code above works fine actually. However, if i put <LastRow = [A65536].End(xlUp).Row>, the the instance EXCEL.EXE will not be removed from memory. Any idea can solve this?