+ Reply to Thread
Results 1 to 5 of 5

Is it possible to Shell and remove Excel from memory?

  1. #1
    Registered User
    Join Date
    04-15-2004
    Location
    Montréal
    Posts
    2

    Is it possible to Shell and remove Excel from memory?

    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 on the Task Manager.

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

    Thanks!

    Alain

  2. #2
    Gary''s Student
    Guest

    RE: Is it possible to Shell and remove Excel from memory?

    Enter and run:

    Sub Macro1()
    ActiveWorkbook.Save
    Application.Quit
    End Sub

    --
    Gary's Student


    "alainB" wrote:

    >
    > 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 on
    > the Task Manager.
    >
    > Is there a way to remove it from memory after saving? I use Excel 97.
    >
    > Thanks!
    >
    > Alain
    >
    >
    > --
    > alainB
    > ------------------------------------------------------------------------
    > alainB's Profile: http://www.excelforum.com/member.php...fo&userid=8367
    > View this thread: http://www.excelforum.com/showthread...hreadid=550622
    >
    >


  3. #3
    Registered User
    Join Date
    04-15-2004
    Location
    Montréal
    Posts
    2
    Yes, Application.Quit! Should work but it is not in my code. Excel is not quitting.

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

    Alain

  4. #4
    Sriram
    Guest

    Re: Is it possible to Shell and remove Excel from memory?

    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



    "alainB" wrote:

    >
    > Yes, Application.Quit! Should work but it is not in my code. Excel is
    > not quitting.
    >
    > Anyway, I found a way to do it. Instead of running my dialer from the
    > Shell directly, I shell to a Batch file that call my dialer. In that
    > case, Application.Quit is working fine.
    >
    > Alain
    >
    >
    > --
    > alainB
    > ------------------------------------------------------------------------
    > alainB's Profile: http://www.excelforum.com/member.php...fo&userid=8367
    > View this thread: http://www.excelforum.com/showthread...hreadid=550622
    >
    >


  5. #5
    Sriram
    Guest

    Re: Is it possible to Shell and remove Excel from memory?

    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



    "alainB" wrote:

    >
    > Yes, Application.Quit! Should work but it is not in my code. Excel is
    > not quitting.
    >
    > Anyway, I found a way to do it. Instead of running my dialer from the
    > Shell directly, I shell to a Batch file that call my dialer. In that
    > case, Application.Quit is working fine.
    >
    > Alain
    >
    >
    > --
    > alainB
    > ------------------------------------------------------------------------
    > alainB's Profile: http://www.excelforum.com/member.php...fo&userid=8367
    > View this thread: http://www.excelforum.com/showthread...hreadid=550622
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1