【问题标题】:How to test if Outlook is open?如何测试 Outlook 是否打开?
【发布时间】:2021-05-28 10:31:21
【问题描述】:

如何测试 Outlook 以绕过打开。

if outlook.application "is available" then
      'run the command for sending an email
else
      'open/display the current users document folder
end if

'do some stuff...

【问题讨论】:

    标签: excel vba outlook


    【解决方案1】:

    以下代码首先检查 Outlook 是否已在运行。如果是这样,则将应用程序分配给 olApp。如果没有,它会启动应用程序(如果可用)并将其分配给 olApp。

    Dim olApp As Object
    
    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    If olApp Is Nothing Then
        Set olApp = CreateObject("Outlook.Application")
    End If
    On Error GoTo 0
    
    If Not olApp Is Nothing Then
        'run the command for sending an email
    Else
        'open/display the current users document folder
    End If
    
    'do some stuff...
    
    Set olApp = Nothing
    

    【讨论】:

      猜你喜欢
      • 2016-07-13
      • 1970-01-01
      • 1970-01-01
      • 2011-09-05
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多