The User Form for the Text Tools utility

When I create a utility, I usually begin by designing the user interface. In this case, it's the dialog box that's displayed to the user. Creating the dialog box forces me to think through the project one more time.

Figure 16-2 shows the UserForm for the Text Tools utility.


■ L*n « 1 -,>• m . Mrn|i iUk'I

■ £ sa

□ Elu ran Ir < til


T"» iü LM «Fil. M


- . * a

P" ■ .J

> ■ 'jt-ÜT'S* -






^f r.dii/111 limai


d d

(1 >-viu


HT+, I

m ^Ml

Figure 16-2: The UserForm for the Text Tools utility.

Figure 16-2: The UserForm for the Text Tools utility.

Notice that the controls on this UserForm are laid out differently from how they actually appear to the user. That's because some options use different controls, and the positioning of the controls is handled dynamically in the code. The controls are listed and described next.

■ The Operation ComboBox: This always appears on the left, and it is used to select the operation to be performed.

■ Procl ComboBox: Most of the text manipulation options use this ComboBox to further specify the operation.

■ Proc2 ComboBox: Two of the text manipulation options use this ComboBox to specify the operation even further. Specifically, this additional ComboBox is used by Add Text and Remove by Position.

■ Check box: The Skip Non-Text Cells check box is an option relevant to some of the operations.

■ Help button: Clicking this CommandButton displays help.

■ Close button: Clicking this CommandButton unloads the UserForm.

■ Apply button: Clicking this CommandButton applies the selected text manipulation option.

■ Progress bar: This consists of a Label control inside a Frame control.

■ Text box: This text box is used for the Add Text option.

Figure 16-3 shows how the UserForm looks for each of the five operations. Notice that the configuration of the controls varies, depending on which option is selected.

figm TmIc CHJby


"WrfF U

! W-p I-iWU' -


. rr-»: .-.¡y


: ~ i

If! I«*!.*!*,




'I |

Inl luiiilht


fT" 1

Figure 16-3: The UserForm layout changes for each operation. Note

You'll notice that this utility violates one of the design rules that I outline earlier in this chapter (see "What Makes a Good Utility? "). Unlike most of Excel's built-in dialog boxes, the Text Tools utility dialog box does not have an OK or a Cancel button, and clicking the Apply button does not dismiss the dialog box. The original version of Text Tools had an OK button and was designed so that clicking OK performed the task and closed the dialog box. User feedback, however, convinced me to change the design. Many people, it turns out, like to perform several different manipulations at one time. Therefore, I changed the utility to accommodate user preferences.

0 0

Post a comment