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. Notice that the configuration of the controls varies, depending on which option is selected.

BS text tools.xla - UserForml (UserForm)

□ED

1 UserForml

1

1 Vpei3:icr: l-ccl

1

1 J 1

^ ^ [

J

' F l-ic ixeels r-ce: 1

Close Apply J

1

1

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

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

You'll notice that the controls on this UserForm are laid out differently from how they actually appear. 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 below.

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

♦ Proc1 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 combo box 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 of 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.

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

You might notice that this utility violates one of my 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 MainForm 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