Microsoft KB Archive/830877

= You cannot remove a custom user form module using a VBA macro in Visio 2007 and in Visio 2003 =

Article ID: 830877

Article Last Modified on 11/10/2006

-

APPLIES TO


 * Microsoft Office Visio Professional 2007
 * Microsoft Office Visio Standard 2007
 * Microsoft Office Visio Professional 2003
 * Microsoft Office Visio Standard 2003

-





SYMPTOMS
When a Microsoft Visual Basic for Applications (VBA) macro in Microsoft Office Visio 2007 and in Microsoft Office Visio 2003 tries to remove a custom user form module that was created on the fly through code, the user form module is not deleted. To create the user form, use the various methods that are available to the following VBA properties:
 * VBComponents
 * Designer
 * CodeModule



CAUSE
This problem occurs when you use the End command to close the custom user form. The End command stops the execution of all code and that will prevent any bootstrap code to run and to clean up any runtime created modules and forms.



RESOLUTION
To resolve this problem, use the Unload function with the Me parameter. This will close the user form and allow subsequent code to run after the form closes.

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.

The following is an example of how to use the Unload function to close a user form: Sub CloseButton1_Click Unload Me End Sub



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Additional query words: vso2007 vso2003 VBA VO11 VO2003

Keywords: kbmacro kbnofix kbprb KB830877

-

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

© Microsoft Corporation. All rights reserved.