Chapter 20. Custom Dialog Boxes

In this chapter:

  • What Is a UserForm Object?

  • Example: Adding a Closing to a Letter

  • Example: A Fax Cover Sheet

  • Example: Quick Selection

Not only does Word have a large number of built-in dialog boxes for gathering user input, but Word also makes it possible to create custom dialog boxes to communicate with the user.

Custom dialog boxes are also called forms or UserForms. My intention here is to present an introduction to the subject, which will provide a good jumping-off point for further study.

Generally speaking, most Word applications will require only very simple forms (if any). For example, you might want to display a form with a text box for text input or some option buttons to select from several choices and some command buttons to execute procedures.

Actually, Microsoft’s Visual Basic is a more appropriate programming environment than Microsoft Office for creating applications that involve complex forms, since it was designed specifically for that purpose. (Also, it is possible to access any of the Office object models from within Visual Basic.)

What Is a UserForm Object?

A UserForm object can be thought of as a standard code module with a visual interface (a form) that is used to interact with the user (hence the term User-Form). However, you must be a bit careful not to take this description too literally. For instance, procedures (even public ones) that are declared in the General section of a UserForm module are generally intended to support ...

Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.