【问题标题】:How can I prevent Excel from opening a userform when opened from a macro in Outlook?从 Outlook 中的宏打开时,如何防止 Excel 打开用户窗体?
【发布时间】:2018-06-07 17:45:13
【问题描述】:

我正在尝试在 Outlook 中创建一个宏,以在 excel 中打开一个文件并从该文件运行一个过程。这段代码做得很好......

Dim ExApp As Excel.Application
Dim ExWbk As Workbook
Set ExApp = New Excel.Application
Set ExWbk = ExApp.Workbooks.Open("D:\Control Verification\Controls Verification Updated.xlsm")
ExApp.Visible = False

ExWbk.Application.Run "Module1.Email_All"

ExWbk.Close SaveChanges:=False

当有人正常打开此工作簿时,我会自动显示 userform 以允许用户选择不同的内容,但是当我从 Outlook 打开它时,我不希望显示此 userform

我只需要访问用户表单中不需要任何选择的不同过程。有任何想法吗?谢谢。

【问题讨论】:

  • 也许您可以使用全局布尔值来确定是否要显示用户表单?

标签: excel vba outlook


【解决方案1】:

使用Application.EnableEvents Property for disabling the Events before you open the workbook

例子

ExApp.EnableEvents = False 
ExApp.Workbooks.Open("Path") ' < Your code here
ExApp.EnableEvents = True

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-06
    • 2017-12-18
    • 1970-01-01
    • 2017-08-27
    • 2021-10-18
    • 2016-03-28
    • 1970-01-01
    相关资源
    最近更新 更多