open Excel from Outlook-upon close, Excel still listed in Processes tab-Task Manager

  • i'm using the following to read public folder emails (orders) and copy to Excel (works well):


    but after the user is done with Excel (closes the App), goes back to Outlook, etc., and later in the day copies out to Excel agian (code below), Excel won't function properly (when i look in Task Manager, the Excel is not listed under the Application tab, but it is still listed in Processes)...?



    ???


    thank you...

  • Re: open Excel from Outlook-upon close, Excel still listed in Processes tab-Task Mana


    Try setting the Objects to Nothing.


    Basically:

    Code
    Set xlApp = Nothing

    at the end of the procedure, and include extra lines for anything that was assigned using the SET keyword...


    Not saying it's a fix, but it should be done in any case.

  • Re: open Excel from Outlook-upon close, Excel still listed in Processes tab-Task Mana


    You have lots of unqualified object references in there:

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: open Excel from Outlook-upon close, Excel still listed in Processes tab-Task Mana


    thank you...


    ?could you explain further (unqualified object references)...?



    ?can i do this before the user closes Excel (Set xlApp = Nothing)?


    thank you.

  • Re: open Excel from Outlook-upon close, Excel still listed in Processes tab-Task Mana


    You were referring simply to

    Code
    ActiveCell = Now() 
    ActiveCell.Offset(0, 1).Value = txtInboxTodaysDate

    which, on the face of it, is fine except the sheet that will be updated is whatever is active at the time the code runs. See Rorys' revised code for a fix.


    Yes, you can set an instance of an object to Nothing in your code, Excel will continue to run as you never told it to quit. Also, it is visible so the user can quit when needed.

  • Re: open Excel from Outlook-upon close, Excel still listed in Processes tab-Task Mana


    For example, in this line:

    Code
    Set sourceWB = Workbooks.Open(strFile, , False, , , , , , , True)


    you have not qualified the Workbooks property with xlApp so you are creating an implicit Excel object reference that you can't destroy, which is why you end up with the orphaned processes. It should be:

    Code
    Set sourceWB = xlApp.Workbooks.Open(strFile, , False, , , , , , , True)


    Same thing with your use of Range and Activecell.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!