how to test for outlook in a specific scenario

↘锁芯ラ 提交于 2019-12-02 13:11:08

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!