Microsoft KB Archive/321242

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

Article ID: 321242

Article Last Modified on 2/12/2007

-

APPLIES TO


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

-



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 &quot;out-of-memory&quot; 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
 Start Microsoft Word, and then press ALT+F11 to start VBA Editor. Add a new UserForm to the project. You do not have to add any code or controls to reproduce the leak.  In the Word ThisDocument code module, add the following code: Private Sub Document_Open UserForm1.Show End Sub  Save the Word document to a local drive, and then close the document (but do not quit Word). 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. 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.</li></ol>

Keywords: kbbug kbfix KB321242

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.