Chapter 3

Creating Custom Dialog Boxes

A dialog box in any Microsoft Windows application serves a number of purposes. It can, for example, provide information by displaying a message, request information by providing a text box for input, and list a set of choices using a list box. In the Microsoft Visual Basic Editor in any of the Office applications, a custom dialog box is called a UserForm. UserForms are the "drawing pad" on which you design custom dialog boxes. In most cases throughout Office, you use UserForms to reproduce built-in dialog boxes. The elements within a UserForm, such as a button, list box, or a text box, are ActiveX controls. Retrieving user input and displaying information are just two of the things you can do with these controls.

After explaining how to build and use UserForms, this chapter goes on to describe how to build a wizard similar in look and style to the wizards used in Word and PowerPoint. Learning to build the wizard dialog box will also help you become familiar with writing the Visual Basic for Applications code that controls elements on the dialog box.

NOTE
Building dialog boxes in the Visual Basic Editor isn't the same as building dialog boxes in the Microsoft Visual Basic 5.0 or 6.0 development products. UserForms in the Visual Basic Editor in Office and forms in Visual Basic 5.0/6.0 use different technologies. In Part 6, Chapters 13 and 14 describe how to create COM add-ins in Visual Basic 6.0. The examples in this chapter use UserForms in the Visual Basic Editor. However, a similar wizard dialog box is built using Visual Basic 6.0 and is provided in the Chapter 14 practice folder. Some differences exist in how these boxes are built, but the coding styles and practice are similar.