0
votes

I checked Excel Application not Closing from Outlook and tried the solution from the voted answer.

To make sure it was nothing else I was doing I wrote the simplest macro for Outlook to only open and close Excel. It's not the end of the world as this background process consumes almost nothing from memory, but it only closes when Outlook (who called it) closes.

I placed this in the "ThisOutlookSession":

Public Sub Test()
    MsgBox "Trying"
    Dim exApp As Excel.Application
    Set exApp = Excel.Application
    exApp.EnableEvents = False 'Originally I didn't placed this, but I saw it on the other posts
    exApp.DisplayAlerts = False 'Originally I didn't placed this, but I saw it on the other posts
    exApp.Visible = False 'Originally I didn't placed this, but I saw it on the other posts
    exApp.Quit
    Set exApp = Nothing
    MsgBox "Finished"
End Sub

Tried on Office 2010 and 2016 with same results.

1
Set exApp = GetObject("Excel.Application") instead of = Excel.Application work?K.Dᴀᴠɪs
Did you really write Set exApp = Excel.Application, or Set exApp = New Excel.ApplicationBigBen
Sorry K.Davis, you're right: not GetObject (i get an runtime error at a memory position) but the "CreateObject("Excel.Application")" makes the difference i did not know it was the one; please, just add it as an answer so i can mark the question as answered, and thank you very muchSammuelMiranda
You are early-binding: Dim exApp As Excel.Application. To be consistent, you should use Set exApp = New Excel.Application instead of CreateObject. The latter is late-binding.BigBen

1 Answers

0
votes

As reffered in the comments i just had to use "CreateObject("Excel.Application")" or "New Excel.Aplication" on the "set exApp = Excel.Application". Doing any of both works perfectlly.