VBA - Closing Outlook

  • Thread starter Thread starter ajliaks
  • Start date Start date
A

ajliaks

Hi all

I need to open Outlook an then closing it.
Opening function works well, but I do not know how to close it.

Could anyone help?
Thanks, Aldo.

I am using this:
'This is working well
Function OpeningOutlookInSelectedFolder()
Application.ActivateMicrosoftApp (xlMicrosoftMail)
End Function

'This is not working
Function ClosingOutlook()
Application.Close
End Functio
 
Courtesy of Vasant Nanavati

Sub CloseOutlook()
Dim OL As Object
On Error Resume Next
Set OL = GetObject(, "Outlook.Application")
On Error GoTo 0
If OL Is Nothing Then
MsgBox "Outlook is not running!"
Else
OL.Quit
End If
End Sub

Regards

Trevor
 
Back
Top