如何在特定情况下测试前景 [英] how to test for outlook in a specific scenario

查看:80
本文介绍了如何在特定情况下测试前景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题的简单版本是这个。

The simple version of the question is this.

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并绕过显示文件夹...

I the email function works great on its own, but i cannot seem to figure out how to test for outlook and bypass to displaying the folder...

推荐答案

以下代码首先检查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

这篇关于如何在特定情况下测试前景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆