Table of contents
TOC
Collapse the table of content
Expand the table of content

UserForm Object

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

A UserFormobject is a window or dialog box that makes up part of an application's user interface. The UserFormscollection is a collection whose elements represent each loaded UserForm in an application. The UserForms collection has a Count property, an Item property, and an Add method. Count specifies the number of elements in the collection; Item (the default member) specifies a specific collection member; and Add places a new UserForm element in the collection. SyntaxUserFormUserForms [ .Item ] (index) The placeholder index represents an integer with a range from 0 to UserForms.Count - 1. Item is the default member of the UserForms collection and need not be specified. Remarks You can use the UserForms collection to iterate through all loaded user forms in an application. It identifies an intrinsic globalvariable named UserForms. You can pass UserForms(index) to a function whoseargument is specified as a UserForm class. User forms have properties that determine appearance such as position, size, and color; and aspects of their behavior. User forms can also respond to events initiated by a user or triggered by the system. For example, you can write code in the Initialize event procedure of the UserForm to initializemodule-level variables before the UserForm is displayed. In addition to properties and events, you can use methods to manipulate user forms using code. For example, you can use the Move method to change the location and size of a UserForm. When designing user forms, set the BorderStyle property to define borders, and set the Caption property to put text in the title bar. In code, you can use the Hide and Show methods to make a UserForm invisible or visible atrun time. UserForm is anObject data type. You can declare variables as type UserForm before setting them to an instance of a type of UserForm declared atdesign time. Similarly, you can pass an argument to aprocedure as type UserForm. You can create multiple instances of user forms in code by using the New keyword in Dim, Set, and Static statements. You can access the collection of controls on a UserForm using the Controls collection. For example, to hide all the controls on a UserForm, use code similar to the following:

For Each Control in UserForm1.Controls
    Control.Visible = False
Next Control
© 2018 Microsoft