XL97: How to Create a Template for a Toolbox Control
ID: Q160473
|
The information in this article applies to:
-
Microsoft Excel 97 for Windows
SUMMARY
The UserForm Toolbox in the Visual Basic Editor contains all the default
controls that you can add to a UserForm. You can add other custom controls
that are installed on your computer. For example, you can add a third type
of control that is a "template" for a control that you already 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 you specify, which makes it
easier to use than resetting the properties of the same default control
each time you add the control to a UserForm.
Creating a Template Control
To create a template CommandButton control, and then add it to the Toolbox,
use the following steps:
- Close and save all workbooks in Microsoft Excel.
- Open a new workbook.
- Start the Visual Basic Editor (press ALT+F11).
- In the Visual Basic Editor, click UserForm on the Insert menu.
This step adds a UserForm to the project. (The Toolbox also appears.)
- Add a CommandButton control to the UserForm.
- If the Properties window is not visible, click Properties Window on
the View menu.
- In the Properties window, change the following properties for the
CommandButton to the following values.
Property Value
-----------------------------------
BackColor Red
Caption My button
ControlTipText This is my button
Font Courier New
NOTE: If you fail to complete the next three steps, the template control
may not be added permanently to the Toolbox.
- On the File menu, click "Close and Return to Microsoft Excel".
- Close and save the file.
- Reopen the file and restart the Visual Basic Editor.
- Drag the customized CommandButton that is on the UserForm onto the
Controls tab of the Toolbox.
This step copies the CommandButton to the Toolbox, which adds a control
that uses all the properties of the CommandButton you created in steps 5
through 7.
- Click the control in the Toolbox that you created in Step 11, and then
add this control to the UserForm.
The control you added to the UserForm is a template of the control you
created earlier. Note that it is not necessary to add a default
CommandButton, and then modify all the properties again.
NOTE: The Name properties for the CommandButtons 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
CommandButton to a UserForm.
Deleting a Template Control
To delete a template control from the Toolbox, use the following steps:
- Right-click the template control in the Toolbox.
- Click Delete New CommandButton on the shortcut menu that appears.
REFERENCES
For more information about customizing toolbox controls, click the Index
tab in Visual Basic for Applications Help, type the following text
toolbox
and then double-click the selected text to go to the "Add a customized
control to the Toolbox" topic.
Additional query words:
97 XL97
Keywords : kbprg kbtool kbui kbdta xlui KbVBA
Version : WINDOWS:
Platform : WINDOWS
Issue type :