Microsoft KB Archive/213770

= XL2000: How to Create a Template for a Toolbox Control =

Article ID: 213770

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q213770





SUMMARY
The UserForm Toolbox in the Visual Basic Editor contains all of the default controls that you can add to a UserForm. You can also add other custom controls to the default Toolbox. For example, you can add a type of control that is a template for a control that you may have already created or customized.

This article describes the process for customizing an existing control and adding a template of the control to the Toolbox.



MORE INFORMATION
A template control retains all the properties that you specify. This makes the control easier to use than having to reset the properties of the control each time you add it to a UserForm.

Part One
To create a template command button control, and then add it to the UserForm Toolbox, follow these steps:
 * 1) Close and save all workbooks in Microsoft Excel.
 * 2) Open a new workbook.
 * 3) Start the Visual Basic Editor (press ALT+F11).
 * 4) In the Visual Basic Editor, click UserForm on the Insert menu.

Part Two
To add a UserForm to the project (the Toolbox also appears), follow these steps:  Add a command button control to the UserForm. If the Properties window is not visible, click Properties Window on the View menu.  In the Properties window, change the properties for the command button to the following values:   Property          Value ---  BackColor         Red Caption          My button ControlTipText   This is my button Font             Courier New 

Part Three
To permanently add the new template control to the Toolbox, follow these steps:
 * 1) On the File menu, click Close and Return to Microsoft Excel.
 * 2) Save and close the file.
 * 3) Reopen the file, and then start the Visual Basic Editor.
 * 4) Drag the customized command button that is on the UserForm onto the Controls tab of the Toolbox.

Part Four
To copy the command button to the Toolbox, which adds a control that uses all the properties of the command button that you created in "Part Two," follow these steps:
 * 1) Click the control that you created in step 4 of "Part Three."
 * 2) Add this control to the UserForm.

The control that you added to the UserForm is a template of the control that you created earlier.

You do not need to modify the properties for the new command button again because the properties for the new command button have been updated automatically according to your template.

The Name properties for the command buttons that you add to the UserForm are CommandButton1 and CommandButton2. The Name property is the only property that is different when you use the template control to add a command button to a UserForm.

Deleting a Template Control
To delete a template control from the Toolbox, follow these steps:
 * 1) Right-click the template control in the Toolbox.
 * 2) Click Delete New CommandButton on the shortcut menu that appears.

