ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA - Closing Outlook (https://www.excelbanter.com/excel-programming/308338-vba-closing-outlook.html)

ajliaks[_34_]

VBA - Closing Outlook
 
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

--
Message posted from http://www.ExcelForum.com


Trevor Shuttleworth

VBA - Closing Outlook
 
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


"ajliaks " wrote in message
...
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 Function


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 03:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com