Page 265 - Excel Progamming Weekend Crash Course
P. 265
n540629 ch19.qxd 9/2/03 9:35 AM Page 240
240 Saturday Evening
User Form Limitations
While a user form is a regular window, it lacks some of the features that many
program windows have. Specifically:
The window cannot be resized by the user (although it can be resized in VBA
code).
The window does not have minimize and maximize buttons.
The window does not have a control menu.
The window can, however, be moved by the user by dragging its title bar.
The UserForm object, as well as the controls that can be placed on a form, have proper-
ties and methods that determine the appearance and behavior of the object and also any
data that is associated with the object. Most objects also can detect events, which for the
most part are user actions such as clicking something with the mouse. By tying these three
elements together — properties, methods, and events — your VBA code can customize the
appearance and behavior of a user form to suit the specific needs of your application.
The task of creating a user form is made fairly simple by the VBA editor. Specifically, the
form designer lets you design a form visually using a WYSIWYG (What You See Is What You
Get) editor. All these topics are covered in this session and the following two sessions.
Form Designer Basics
To add a new user form to an Excel project, be sure that the correct project is selected in
the Project window. Select Insert ➪ User Form from the VBA Editor menu. The editor opens a
new, blank user form. This and other screen components involved in creating user forms are
shown in Figure 19-1 and explained here:
The user form itself (blank in this figure) is where you place controls to create the
visual interface.
Displayed while the user form is active, the toolbox contains icons for the various
controls that can be placed on a form, as well as an arrow icon, which you select
when you want to work with existing controls on the form.
The Properties window displays the properties for the currently selected object.
This may be the user form itself or a control on the form.
The Project window lists all forms that are part of each project under the Forms
node.
The View Code and View Object buttons let you switch between viewing the user
form’s visual interface or its VBA code-editing window.