Each dialog box that you create is stored in its own UserForm object — one dialog box per UserForm. You create and access these UserForms in the Visual Basic Editor.
Inserting a new UserForm
To insert a UserForm object with the following steps:
- In the macro, you can insert User form with following 2 ways:
- From “Menu Bar” ⇨ “UserForm”
- From “Standard Toolbar” by clicking “Insert UserForm”
- If “Property window” is not available in your macro, press F4 to display “Property window”.
The VBE insert a new UserForm object with an empty dialog box.
The VBE inserts a new UserForm object, which contains an empty dialog box.
Below figure shows a UserForm — an empty dialog box with some controls in Toolbox.
Adding controls to a UserForm
When you activate a UserForm, the VBE displays the Toolbox in a floating window, as shown in the above figure. You use the tools in the Toolbox to add controls to your UserForm. If the Toolbox doesn’t appear when you activate your UserForm, choose View ⇨ Toolbox.
To add a control, just click the desired control in the Toolbox and drag it into the dialog box to create the control. After you add a control, you can move and resize it by using standard techniques.
Below table indicates the various tools, as well as their capabilities. To determine which tool is which, hover your mouse pointer over the control and read the small pop-up description.
ToolBox Control | |
---|---|
Controls | What it does |
Label | Shows text |
TextBox | Determines which of the file filters the dialog box displays by default. |
ComboBox | Display a drop-down list. |
ListBox | Display a list of items. |
CheckBox | Useful for On/off or Yes/No options. |
OptionButton | Used in groups; allows the user to select one of several options. |
ToggleButoon | A button that is either on or off. |
Frame | A container for other control. |
CommandButton | A clickable button. |
TabStrip | Display Tabs |
MultiPage | A tabbed container for other objects. |
ScrollBar | A draggable bar. |
SpinButton | A clickable button often used for changing a value. |
Image | Contains an image |
RefEdit | Allows the user to select a range. |
No comments:
Post a Comment