-
Does anyone know of a way to close Outlook via a VB program?
I wrote a clumsy program which opens Outlook and sends keys to exit and log off, but there are too many situation the sendkeys routine doesn't work. I am looking at backup solutions for our company and one of the big problems is most backup programs cannot back up open files. Outlook's .pst files are the most important files for us to be able to back up but if a user leaves Outlook open, the .pst file won't be backed up.
Any help would be appreciated.
Thanks,
[email protected]
-
Try the Kill command it works great for M$ programs.
-
Isn't Kill for deleting files? I'm looking to close Outlook, not to delete any files.
-
Try sending this to outlook
Hope this helps
-
This works with Outlook 2000. Not sure if Outlook 97/98 has an object model you can hook into.
Code:
Dim Outlook As Object
On Error Resume Next
'Set will error if outlook isnt running. So Outlook will be nothing
Set Outlook = GetObject(, "Outlook.Application")
If Outlook Is Nothing Then
Outlook.Quit
Set Outlook = Nothing
End If
-
Thanks Ruxpin! The code you gave didn't quite work but it was close enough that I was able to figure it out. Here's what worked:
Option Explicit
Dim Outlook As Object
Private Sub Form_Load()
On Error Resume Next
'Set will error if outlook isnt running. So
'Outlook will be nothing
Set Outlook = GetObject(, "Outlook.Application")
If Outlook Is Nothing Then End
Outlook.Quit
Set Outlook = Nothing
End
End Sub
-
Wooops yeah sorry, was supposed to be
Code:
If Not Outlook Is Nothing Then