问题
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...
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...
回答1:
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
来源:https://stackoverflow.com/questions/51796218/how-to-test-for-outlook-in-a-specific-scenario