Page 270 - Excel Progamming Weekend Crash Course
P. 270
n540629 ch19.qxd 9/2/03 9:35 AM Page 245
Session 19 — Creating Custom Dialog Boxes with User Forms 245
Table 19-2 Settings for the UserForm Object’s StartUpPosition Property
Constant Effect
Manual Position is determined by the Top and Left properties.
CenterOwner If Excel is displayed, the form is centered with respect to the Excel
window. If Excel is not displayed, the form is centered on-screen.
CenterScreen The form is centered on-screen.
WindowsDefault The form is positioned at the top left of the screen.
The ShowModal property is usually left at its default value of True. This is appropriate for
most user forms because it would not make sense for the program to continue operating
until the form is closed (for example, when the form is used to accept input of data from
the user). In some special cases, however, you would want to set this property to False. One
example is when you create a user form to display instructions on program use to the user.
It is then desirable to keep that user form displayed while the user works in another form.
Form Methods
The UserForm object has several methods. The ones that you are likely to need are
described in Table 19-3.
Table 19-3 Selected methods of the UserForm Object
Method Description
Hide Hides the form if it is displayed; otherwise, it has
no effect.
Move(Left, Top, Width, Height) Moves the form and changes its size according to
the arguments. Arguments are optional; any that
are omitted are left at the current values.
PrintForm Prints the form on the default printer
Show Displays the form (and loads it if it is not already
loaded)
Calling the Move method on the user form has the same effect as setting its
Top, Left, Width, and Height properties.
Tip