Private Sub fireOutlook() Dim olShellVal As Long On Error GoTo FIREOUTLOOK_ERR Set g_olApp = GetObject(, "Outlook.Application") ' If outlook is open will create obj ' If closed this will goto the error handler and then resume If g_olApp Is Nothing Then ' This checks if object was created olShellVal = Shell("OUTLOOK", vbNormalNoFocus) ' Opens Outlook Set g_olApp = CreateObject("Outlook.Application") ' Creates the Object End If FIREOUTLOOK_EXIT: Exit Sub FIREOUTLOOK_ERR: If g_olApp Is Nothing Then Err.Clear Resume Next Else MsgBox Err.Description, , "Error Number: " & Err.Number End If GoTo FIREOUTLOOK_EXIT End Sub
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter