VBA for Excel 2007 tutorial-Form |
||||||||||||||
Form
-Creating a form in Excel 2007In Excel 2007, you can create a form by selecting UserForm as you have seen in the picture above.-Setting up form propertiesAfter creating a form you can set its properties such as Name, BackColor, BorderStyle, Caption through the form properties window. To show the form property window, you can press F4 or click Properties Window in the ribbon menu.
The common properties of the form are Name, BackColor, BorderStyle, Caption, Picture, and ScrollBars. -Name: The Name property defines the name of the form. The default name of the form is UserForm1, or UserForm2, UserForm3,etc. You can change the name form by editing the default name. By setting the name of the form, you will find it easy to refer to the form in VBA code. -BackColor: You can use the BackColor property to set the background color of the form based on the color value that you like. -BorderStyle: By setting BorderStyle property to 0-fmBorderStyleNone, the form will display without border. However, if you want to display the form with border you can choose 1-fmBorderStyleSingle. -Caption: The Caption property gives the users more information about what you want to form to play the role. For example, if the form is about information of students, you may set the Caption property to Student Information or Student Form. -Picture: If you want to display a picture as the background of the form, You need to used the Picture property that allows you to select a picture of your choice. This Picture can be used in conjunction with the PictureSizeMode property to determine whether you want to display the picture in stretch mode, zoom mode, or clip mode. -ScrollBars: If there are a lot of information on the form that the user finds hard to see all information, you need to used the ScrollBars. By using the ScrollBars property, your form can be scrolled vertically or horizontally. You can choose one of the ScrollBars values: +0-fmScrollBarsNone to disable scroll bars on the form. +1-fmScrollBarsHorizontal to show only horizontal scroll bar. +2-fmScrollBarsVertical to show only vertical scroll bar. +3-fmScrollBarsBoth to show both horizontal and vertical scroll bars. |
| |||||||||||||
|
||||||||||||||