Sei sulla pagina 1di 11

ummary of ActiveX controls

Button Example Descriptio


Name n
Check box Turns on or off a value that
indicates an opposite and
unambiguous choice. You can
select more than one check box at
a time on a worksheet or in a
group box. A check box can have
one of three states: selected
(turned on), cleared (turned off),
and mixed, meaning a combination
of on and off states (as in a
multiple selection).
Button Example Descriptio
Name n
Text box Enables you to, in a rectangular
box, view, type, or edit text or data
that is bound to a cell. A text box
can also be a static text field that
presents read-only information.
Command Runs a macro that performs an
button action when a user clicks it. A
command button is also referred to
as a push button.
Option Allows a single choice within a
button limited set of mutually exclusive
choices usually contained in a
group box or frame. An option
button can have one of three
states: selected (turned on), cleared
Button Example Descriptio
Name n
(turned off), and mixed, meaning a
combination of on and off states
(as in a multiple selection). An
option button is also referred to as
a radio button.
List box Displays a list of one or more items
of text from which a user can
choose. Use a list box for
displaying large numbers of
choices that vary in number or
content. There are three types of
list boxes:

 A single-selection list box


enables only one choice. In this
case, a list box resembles a group
Button Example Descriptio
Name n

of option buttons, except that a list


box can handle a large number of
items more efficiently.
 A multiple selection list box
enables either one choice or
contiguous (adjacent) choices.
 An extended-selection list box
enables one choice, contiguous
choices, and noncontiguous (or
disjointed) choices.
Button Example Descriptio
Name n
Combo Combines a text box with a list box
box to create a drop-down list box. A
combo box is more compact than a
list box, but requires the user to
click the down arrow to display the
list of items. Use to allow a user to
either type an entry or choose only
one item from the list. The control
displays the current value in the
text box, regardless of how that
value is entered.
Toggle Indicates a state, such as Yes/No,
button or a mode, such as On/Off. The
button alternates between an
enabled and disabled state when it
Button Example Descriptio
Name n
is clicked.
Spin Increases or decreases a value, such
button as a number increment, time, or
date. To increase the value, click
the up arrow; to decrease the value,
click the down arrow. Typically, a
user can also type a text value into
an associated cell or text box.
Scroll bar Scrolls through a range of values
when you click the scroll arrows or
drag the scroll box. In addition, you
can move through a page (a preset
interval) of values by clicking the
area between the scroll box and
either of the scroll arrows. Typically,
Button Example Descriptio
Name n
a user can also type a text value
directly into an associated cell or
text box.
Label Identifies the purpose of a cell or
text box, displays descriptive text
(such as titles, captions, pictures),
or provides brief instructions.
Image Embeds a picture, such as a bitmap,
JPEG, or GIF.

Frame A rectangular object with an


control optional label that groups related
controls into one visual unit.
Typically, option buttons, check
boxes, or closely related contents
Button Example Descriptio
Name n
are grouped in a frame control.
Note: The ActiveX frame control is not available in the ActiveX
Controls section of the Insert command. However, you can add
the control from the More Controls dialog box by
selecting Microsoft Forms 2.0 Frame.

More Displays a list of additional ActiveX


Controls controls available on your
computer that you can add to a
custom form, such as Calendar
Control 12.0 and Windows Media
Player. You can also register a
custom control in this dialog box.

Drawing Tool objects


 You may also want to include SmartArt graphics, Shapes, WordArt, and text
boxes on your form. You can resize, rotate, flip, color, and combine these objects to create even more complex shapes.
When you type text directly in a Shape or text box object, the text becomes part of that object — if you rotate or flip the
object, the text rotates or flips with it. Unlike ActiveX controls, you can assign different attributes, such as font size and
font style, to individual words and characters in the object. You can also assign macros and add hyperlinks to these
objects. You can even link text in a Shape or text box object to a worksheet cell and dynamically display updated values in
those objects.

Working with controls and objects on the worksheet form

After adding forms and ActiveX to a worksheet form, you usually want to fine-tune and rearrange the controls in a variety
of ways to create a well-designed, user friendly form. Common tasks include the following:

 Controlling the display of gridlines while you work with the controls, and deciding whether to display the gridlines
to the user on the final worksheet form.
 Selecting and deselecting controls so that you can specify properties or make additional adjustments.
 Editing text in a control, such as the caption or label.
 Grouping, copying, moving, and aligning controls to organize the layout of the worksheet form.
 Resizing and formatting controls to obtain the appearance that you want.
 Positioning or sizing a control with a cell.
 Protecting controls and linked cells according to your specific data protection needs.
 Enabling or disabling the printing of controls when the worksheet form is printed.
 Deleting unused controls.
You can design a worksheet form with or without cell gridlines in the background. For example, you might want to turn off
cell gridlines and then format all the cells with the same color or pattern, or even use a picture as a sheet background. To
hide or show the gridlines, on the View tab, in the Show/Hide group, clear or select the Gridlines check box.

Determining the type of control that is on your worksheet

Because there are three different types of controls and objects that you can modify uniquely, you might not know for sure
which type of control it is just by looking at it. To determine the type of control (Form or ActiveX), select and right-click the
control, and then display the shortcut menu:

 If the shortcut menu contains the command Properties, the control is an ActiveX control, and you are in design
mode.
 If the shortcut menu contains the command Assign Macro, the control is a Form control.

Tip: To display the correct shortcut menu for the group box Form control, make sure that you select the perimeter instead of the interior of
the group box.

 If the shortcut menu contains the command Edit Text, the object is a Drawing object.

VBA UserForms
For maximum flexibility, you can create UserForms, which are custom dialog boxes, that usually include one or more
ActiveX controls. You make UserForms available from VBA code that you create in the Visual Basic Editor. The high-level
steps for creating a UserForm are as follows:

1. Insert a UserForm into your workbook's VBAProject. You access a workbook's VBAProject by first displaying the
Visual Basic Editor (press ALT+F11) and then, on the Insert menu, clicking UserForm.
2. Write a procedure to display the UserForm.
3. Add ActiveX controls.
4. Modify properties for the ActiveX controls.
5. Write event-handler procedures for the ActiveX controls.

By using UserForms, you can also utilize advanced form functionality,. For example, you can programmatically add a
separate option button for each letter of the alphabet or you can add a check box for each item in a large list of dates and
numbers.

Before creating a UserForm, consider using built-in dialog boxes available from Excel that might fit your needs. These
built-in dialog boxes include the VBA InputBox and MsgBox functions, the
Excel InputBoxmethod, GetOpenFilename method, GetSaveAsFilename method, and the Dialogs object of
the Application object, which contains all the built-in Excel dialog boxes.

Potrebbero piacerti anche