Is it possible to Shell and remove Excel from memory?

A

alainB

Hi,

Here is my code for sorting my phone database:

Sub Sort1()
Range("A1").Select
Selection.Sort Key1:=Range("A2"), _
Order1:=xlAscending, Key2:=Range("B2"), _
Order2:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom

ActiveWorkbook.Save
SendKeys "%{F4}"
s$ = Shell("C:\Documents and Settings\Alain\Bureau\ _
MyDialer.exe", vbNormalFocus)
End Sub

After editing, sorting and saving my database, I want to run my Dialer
It is working fine except that Excell stay in memory. I can see that o
the Task Manager.

Is there a way to remove it from memory after saving? I use Excel 97.

Thanks!

Alai
 
A

alainB

Yes, Application.Quit! Should work but it is not in my code. Excel i
not quitting.

Anyway, I found a way to do it. Instead of running my dialer from th
Shell directly, I shell to a Batch file that call my dialer. In tha
case, Application.Quit is working fine.

Alai
 
S

Sriram

Alain

Try this

Try

....

Finally
NAR(m_objSheet)
m_objSheet = Nothing
NAR(objWorkbook) ' This is required - MS Excel has an inherent bug.
objWorkbook = Nothing
objExcel.Quit()
NAR(objExcel)
objExcel = Nothing
End Try
....

Private Sub NAR(ByVal objExcelRelated As Object)
Try

System.Runtime.InteropServices.Marshal.ReleaseComObject(objExcelRelated)
Catch
Finally
objExcelRelated = Nothing
End Try
End Sub
 
Top