OL2002: Other Programs Do Not Work After You Quit Outlook 2002 (324921)



The information in this article applies to:

  • Microsoft Outlook 2002

This article was previously published under Q324921

SYMPTOMS

If you start Outlook 2002, run a second program (for example, Microsoft Visual Basic or a Microsoft Visual Basic for Applications program) that accesses Outlook 2002, and then quit Outlook 2002 while you still have the second program running on your computer, you may experience one of the following symptoms:
  • You receive an error message that is similar to the following:
    Microsoft Visual Basic Run-time error '462'

    The remote server machine does not exist or is unavailable
    -or-

  • Another program that automates Microsoft Outlook does not work.

CAUSE

This behavior occurs because previous versions of Outlook allowed multiple instances to continue running after Outlook was closed. Outlook appeared to stop responding (hang) after you closed the program, when in fact a different program was still using Outlook.

To prevent this behavior, Outlook 2002 was designed to close all instances when you close the program.

WORKAROUND

Use one of the following methods to work around this behavior:
  • Start your custom program before you start Outlook 2002. When you start the programs in this order, a reference is kept open for Outlook 2002, and your custom program works as it did with previous versions of Outlook. -or-

  • Modify your custom program code so that it traps for the error condition, and then reinitializes the Outlook object model.

    Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: The following example is a sample code for a button click that traps the error condition, and then reinitializes the Outlook object model:
    Sub CommandButton1_Click()
        On Error Resume Next
        MsgBox ns.CurrentUser.Name
        If Err.Number <> 0 Then
    	   MsgBox Err.Description
            Set oL = CreateObject("Outlook.Application")
            Set ns = oL.Session
            MsgBox ns.CurrentUser.Name
            Err.Clear
        End If
    End Sub
    						

Modification Type:MajorLast Reviewed:6/17/2005
Keywords:kberrmsg kbprb KB324921