Article ID: 213582 - Last Review: October 11, 2006 - Revision: 4.2 XL2000: Problems When You Use Macro to Add Control to UserFormThis article was previously published under Q213582 SYMPTOMS
In Microsoft Excel, you may have difficulty adding a control to a
user form programmatically. For example, if you run the following macro
code you do not receive an error, but the check box control is not added to the user form:
CAUSE
This macro does not add the control to the user form because this syntax for the Add method only applies during run time. That means you have to include this macro code in an event procedure tied to the user form.
RESOLUTIONMicrosoft 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.
If you want use the macro described in the "Symptoms" section to add a check box control to a user form during run time:
NOTE: When you dismiss the user form, the check box does not remain on the user form. To programmatically add a control to a user form so that it becomes part of the user form, you must add it during design time. To do this:
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. REFERENCESFor more information about adding controls to a user form, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Adding Controls to a User Form in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
| Article Translations
|
Back to the top
