本文介绍了如何测试 Outlook 是否打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何测试 Outlook,绕过打开.

How do I test for Outlook, to bypass opening.

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...

推荐答案

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

The following code first checks whether Outlook is already running. If so, the application is assigned to olApp. If not, it starts the application, if available, and assigns it to 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

这篇关于如何测试 Outlook 是否打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 04:27