Results 1 to 7 of 7

Thread: Closing Outlook

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    12
    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]

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Try the Kill command it works great for M$ programs.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    12
    Isn't Kill for deleting files? I'm looking to close Outlook, not to delete any files.

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Try sending this to outlook

    Code:
    SendKeys "%{F4}"
    Hope this helps

  5. #5
    Lively Member
    Join Date
    Mar 2000
    Posts
    87
    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

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    12
    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

  7. #7
    Lively Member
    Join Date
    Mar 2000
    Posts
    87
    Wooops yeah sorry, was supposed to be

    Code:
    If Not Outlook Is Nothing Then

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width