560 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Drawing UserForms in the VBA code editor Part four of a seven-part series of blogs |
---|
Learn how to create your own custom dialog boxes in VBA, using UserForms. This is the first part of a three-part series (the other parts are on Writing Code for UserForms and Creating Advanced Controls).
This blog is part of our Excel VBA tutorial series. We also run training classes in Excel and courses in VBA.
|
To format any controls on a form, you first need to know how to select it/them. We'll look first at selecting one control, then at how to select lots of controls at the same time (the next part of this blog will then show how to format controls and forms).
To change the format of a single control, click on it to select it and use the Properties window:
Right-click on any control to show its properties, as shown here, if they're not already visible (as already mentioned, you can also press F4 at any time to bring up the Properties window).
Alternatively, you can select a control in the Properties window itself:
Click on the drop arrow shown to choose the control whose properties you want to change.
There are several ways you can select lots of controls at the same time. The easiest way is probably with the mouse button:
Click and drag on the form to draw a rectangle, making sure that you start on a blank part of the form. Any control that this rectangle touches or encloses will be selected. This example would select all 3 controls.
Alternatively, you could use the SHIFT or CTRL keys:
In this example, if you click on the OK button as shown:
Alternatively, you could press CTRL + A to select every control on the form in one go.
If you select multiple controls, one (and only one) of them will have white handles surrounding it; all of the others have black ones. The one with the white handles is called the dominant control:
Here the label containing Name: is the dominant control. If you have a number of controls selected, you can click on any one of them to make that one the new dominant control among those selected.
What this means is that if you choose to align or size the selected controls (as shown later in this blog), they will do be aligned or size by reference to the dominant control:
The results of aligning the controls shown above by their left edges. Everything lines up to the red line shown, since that is the left edge of the dominant control.
If you want to change properties for a form (such as its name), you need to select it:
Click anywhere on a form apart from on one of its controls to select it, as shown here.
Now that you know how to select a form or its controls, it's time to look at how to format it/them.
Parts of this blog |
---|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2023. All Rights Reserved.