Microsoft Office Tutorials and References
In Depth Information
Adjusting UserForm Controls
The Image control Picture property is worth mentioning because you can either select a
graphic file that contains the image or paste an image from the Clipboard. When pasting an
image, first copy it to the Clipboard; then select the Picture property for the Image control,
and press Ctrl+V to paste the Clipboard contents.
If you select two or more controls at once, the Properties window displays only the
properties that are common to the selected controls.
The UserForm itself has many properties that you can adjust. Some of these properties
are then used as defaults for controls that you add to the UserForm. For example, if you
change the UserForm Font property, all controls added to the UserForm will use that
font. Note, however, that controls already on the UserForm aren’t affected.
Common properties
Although each control has its own unique set of properties, many controls have some common
properties. For example, every control has a Name property and properties that determine its
size and position ( Height , Width , Left , and Right ).
If you’re going to manipulate a control by using VBA, it’s an excellent idea to provide a
meaningful name for the control. For example, the first OptionButton that you add to a UserForm has a
default name of OptionButton1 . You refer to this object in your code with a statement such as
the following:
OptionButton1.Value = True
But if you give the OptionButton a more meaningful name (such as obLandscape ), you can use
a statement such as this one:
obLandscape.Value = True
Many people find it helpful to use a name that also identifies the type of object. In the
preceding example, I use ob as the prefix to identify the control as an OptionButton.
I’m not aware of any standard prefixes, so feel free to invent your own.
You can adjust the properties of several controls at once. For example, you might have several
OptionButtons that you want left-aligned. You can simply select all the OptionButtons and then
change the Left property in the Properties box. All the selected controls will then take on that
new Left property value.
The best way to learn about the various properties for a control is to use the Help system. Simply
click on a property in the Property window and press F1. Figure 13-7 shows an example of the
type of help provided for a property.
 
Search JabSto ::




Custom Search