简体   繁体   English

Excel 应用程序未从 Outlook VBA 关闭

[英]Excel Application not closing from Outlook VBA

I checked Excel Application not Closing from Outlook and tried the solution from the voted answer.我检查了Excel Application not Closing from Outlook并尝试了投票答案中的解决方案。

To make sure it was nothing else I was doing I wrote the simplest macro for Outlook to only open and close Excel.为了确保我没有做其他事情,我为 Outlook 编写了最简单的宏,只打开和关闭 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.这不是世界末日,因为这个后台进程几乎不会从 memory 消耗任何东西,但它只会在 Outlook(谁叫它)关闭时关闭。

I placed this in the " ThisOutlookSession ":我把它放在“ 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.在 Office 2010 和 2016 上进行了尝试,结果相同。

As reffered in the comments i just had to use "CreateObject("Excel.Application")" or "New Excel.Aplication" on the "set exApp = Excel.Application".正如评论中提到的,我只需要在“set exApp = Excel.Application”上使用“CreateObject(”Excel.Application“)”或“New Excel.Aplication”。 Doing any of both works perfectlly.两者中的任何一个都可以完美地完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM