Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBScript Help! Ending Outlook.exe

$
0
0

Hi, I am somewhat familiar with VBS, but not very good at making my own scripts.

I need to be able to close outlook regardless of there being other windows open like new e-mails with unsaved data in them.

I want it to go something like this:

If Outlook.exe is running
do exit outlook.exe
If outlook.exe is NOT running
End this script

I dont want my script to continue running if Outlook is completely closed.

I have two scripts that help me accomplish this, but they both continue to run even though Outlook is not there anymore.

Dim oOL 'As Outlook.Application
Set oOL = GetObject(, "Outlook.Application")
If oOL Is Nothing Then
Else
Do
'Outlook running
oOL.Session.Logoff
oOL.Quit
Loop
End If
Set oOL = Nothing

__________________

WScript.Sleep 300
Set wshShell = CreateObject("WScript.Shell")
Do
    ret = wshShell.AppActivate("Microsoft Outlook")
    If ret = True Then
        wshShell.SendKeys "{Y}"
WScript.Sleep 300
    End If
Loop


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>