Share this Page URL

Chapter 18. Working with VBA > UserForms - Pg. 439

Figure 18-10. A newly created UserForm with several controls UserForms Word UserForms are actually Office UserForms, which are hosted by most Office applications. They have a different object model than Word, so if you start working with them extensively, you will need to familiarize yourself with the Forms object library (MSForms in the Libraries drop-down box in the VBA window). But you can create and work with UserForms in the VBA window without using the Forms object model in code, and these forms are very useful for intermediate and advanced Word programming. UserForms allow you to go beyond a simple message box or input box and present users with a more extensive dialog box with (for example) combo boxes or list boxes where items can be selected, and text boxes for entering values. To create a UserForm, open the VBA window, select the appropriate document or template in the Project Explorer, and click the Insert UserForm button on the tool- bar. A new form opens (Figure 18-10), called UserForm1 (or a higher number, if there already are some forms for this template). When the UserForm has the focus, a Toolbox appears, with a selection of controls you can place on the form. UserForms (and controls placed on them) have several useful events: Working with VBA UserForms | 439