Microsoft KB Archive/292796

From BetaArchive Wiki

Article ID: 292796

Article Last Modified on 3/1/2004



APPLIES TO

  • Microsoft Outlook 2002 Standard Edition



This article was previously published under Q292796


SYMPTOMS

In Microsoft Outlook Visual Basic for Applications, global variables are not available in the Application_Quit event. In addition, other code that you are using in the Quit event may not function as expected.

CAUSE

The Quit event runs after Outlook has already released, or destroyed, the variables.

WORKAROUND

Implement a COM add-in instead of using Outlook Visual Basic for Applications. For additional information about creating a COM add-in for Outlook, click the article number below to view the article in the Microsoft Knowledge Base:

291163 OL2002: How to Create a COM Add-in for Outlook


STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Problem

  1. Add the following Outlook Visual Basic for Applications code to the ThisOutlookSession code window:

    Option Explicit
    
    Dim myInteger As Integer
    
    Sub Application_Quit()
      MsgBox myInteger
    End Sub
    
    Sub Application_Startup()
      myInteger = 10
    End Sub
                        
  2. Run the Application_Startup event.
  3. Quit Outlook.

The code in the Application_Quit event will run and display a message that indicates that the value of the myInteger variable is zero (0). If the variable were still valid, the value would be 10.

REFERENCES

For additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:

287530 OL2002: Questions About Custom Forms and Outlook Solutions



Additional query words: OutSol OutSol2002

Keywords: kbbug kbnofix KB292796