30.04.2017 Views

4523756273

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

270<br />

Part IV: Communicating with Your Users<br />

Follow along to add a control to the UserForm:<br />

1. Click the Toolbox tool that corresponds to the control you want to add.<br />

2. Click in the UserForm and drag to size and position the control.<br />

Alternatively, you can simply drag a control from the Toolbox to the<br />

UserForm to create a control with the default dimensions. Figure 17-1<br />

shows a UserForm that contains a few controls.<br />

Figure 17-1:<br />

A UserForm<br />

with a few<br />

controls<br />

added.<br />

A UserForm may contain vertical and horizontal grid lines, which help align<br />

the controls you add. When you add or move a control, it snaps to the grid. If<br />

you don’t like this feature, you can turn off the grids by following these steps:<br />

1. Choose Tools➪Options in the VBE.<br />

2. In the Options dialog box, select the General tab.<br />

3. Set your desired options in the Form Grid Settings section.<br />

Introducing control properties<br />

Every control that you add to a UserForm has properties that determine how<br />

the control looks and behaves. You can change a control’s properties at the<br />

following two times:<br />

✓ At design time — when you’re designing the UserForm. You do so manually,<br />

using the Properties window.<br />

✓ At runtime — while your macro is running. You do so by writing VBA<br />

code. Changes made at runtime are always temporary; they are made to<br />

the copy of the dialog box you are showing, not to the actual UserForm<br />

object you designed.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!