问题描述
我已经检查了该帖子: Excel应用程序未从Outlook关闭并从投票的答案中尝试解决方案;它仍然没有关闭.
I already checked this post: Excel Application not Closing from Outlook and tried the solution from the voted answer; it still doesn't close.
因此,为确保我没有做其他事情,我为Outlook编写了最简单的宏,使其仅打开和关闭Excel,但仍未关闭.好的,这不是世界末日,因为该后台进程很小,几乎不消耗内存,但是它仅在Outlook(称为它)关闭时关闭,而实际上不应该关闭,因此,我正在尝试解决这个问题.
So to make sure it was nothing else i was doing i wrote the simplest macro for outlook to only just open and close Excel, and it still doesn't close. Ok, it's not the end of the world as this background process is small and consumes almost nothing from memory, but it only closes when outlook (who called it) closes, and it shouldn't, so I'm trying to resolve it.
看到我放在" ThisOutlookSession "上的这个小宏:
See this little macro I placed on 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, still no use
exApp.DisplayAlerts = False 'Originally I didn't placed this, but I saw it on the other posts, still no use
exApp.Visible = False 'Originally I didn't placed this, but I saw it on the other posts, still no use
exApp.Quit
Set exApp = Nothing
MsgBox "Finished"
End Sub
无论如何,它都会使Excel在后台保持打开状态.谁能告诉我为什么?在Office 2010和2016上进行了尝试,结果相同.
It keeps Excel open in background anyway. Can anyone tell me why? Tried on Office 2010 and 2016 with same results.
推荐答案
正如评论中提到的,我只需要使用"CreateObject("Excel.Application"))"即可;或"New Excel.Aplication"在设置exApp = Excel.Application"上.两者都可以完美地工作.
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.
这篇关于Excel应用程序无法从VBA Outlook宏关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!