BUG: A GDI Resource Leak Occurs When a Visual Basic for Applications UserForm Is Displayed (321242)



The information in this article applies to:

  • Microsoft Visual Basic for Applications (VBA) Software Development Kit (SDK) 6.0
  • Microsoft Office 2000 Developer
  • Microsoft Office XP Developer

This article was previously published under Q321242

SYMPTOMS

If a Visual Basic for Applications (VBA) host program loads and displays a UserForm, at least two Graphics Device Interface (GDI) handles may be leaked and may not be reclaimed until the host process exits. This problem occurs when the VBA project loads the UserForm the first time.

If the host program loads and unloads projects repeatedly, these leaks can cause the operating system to become low on system resources and not to redraw the program correctly, or can cause an "out-of-memory" error message.

STATUS

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

MORE INFORMATION

This problem may occur with Microsoft Office 2000 and Microsoft Office XP programs, and with third-party programs that incorporate VBA.

Steps to Reproduce the Problem

  1. Start Microsoft Word, and then press ALT+F11 to start VBA Editor.
  2. Add a new UserForm to the project. You do not have to add any code or controls to reproduce the leak.
  3. In the Word ThisDocument code module, add the following code:
    Private Sub Document_Open()
        UserForm1.Show
    End Sub
    					
  4. Save the Word document to a local drive, and then close the document (but do not quit Word).
  5. Open the Word document that you saved. If you are prompted, turn on macros. The UserForm is displayed. Close the UserForm by clicking the Close button on the title bar.
  6. Close the Word document (but do not quit Word). VBA leaks roughly two GDI handles each time that you open the document and the UserForm is displayed.

Modification Type:MajorLast Reviewed:10/22/2002
Keywords:kbbug KB321242