Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close Outlook command line 2

Status
Not open for further replies.

rgbanse

MIS
Jun 4, 2001
211
US
Good Day
I can use the following to open Outlook:

Function OpenOutlook()
Call Shell("C:\Program Files\Office2K\Office\Outlook.exe")
End Function

Is there a command line for closing Outlook?
thx
RGB
 
close outlook client,
part1:
Public Sub close_Outlook()
Dim myOlApp As Object
Set myOlApp = GetObject(, "Outlook.application")
myOlApp.Quit
End Sub

[wiggle] ide
 
part2:
instead of using shell function use

Sub RunAndCloseOutlookApp()
Dim myOlApp As Object
Dim myNameSpace As Object

'running new outlook app.
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
myNameSpace.GetDefaultFolder(5).Display

'close active explorer:
myOlApp.ActiveExplorer.Close

'or to close all client:
'myOlApp.Quit
End Sub
ide
 
Because Outlook 2K is a single-instance application, ide's first post is the proper way to shutdown Outlook.

AFA not using the Shell function to start Outlook, that depends. If he wants Outlook to remain open outside his original function, he'll need to use the Shell function (or one of it's variations) or use a variable with scope beyond or above that function. Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top