Setting User Form Properties

UserForm properties control a form's physical appearance. The UserForm.Caption property defines the text that appears on the left-hand side of the UserForm title bar, as shown in Figure 3-4.

UserForms in AutoCAD 2000 VBA are modal and therefore don't contain a minimize or maximize button on the right side of the UserForm title bar. UserForms in AutoCAD 2002 through 2006 VBA (VBA 6.3), however, can be either modal or modeless.

Figure 3-4. The Caption property of UserForm

■ Note When the ShowModal property is set to False, you may work outside the UserForm at run time. Normally, the UserForm focus remains off even while you work in the UserForm. By setting a Reference to the AutoCAD Focus Control for VBAType Library (acFocusCtrl16.dll in the AutoCAD folder) and then adding acFocusCtrl (a transparent Control that will appear on the Control Toolbox) to the UserForm, focus will remain on the UserForm until you click outside of it.

The UserForm.Height and UserForm.Width properties control the initial UserForm height and width, respectively, as shown in Figure 3-5.

Excel Vba Userform Titlebar
Figure 3-5. The Width and Height properties of UserForm

However, you may change these properties at run time as demonstrated in the following example:

Private Sub UserForm_Activate() UserForm1.Width = 200 UserForm1.Height = 150 End Sub

In this example, the UserForm's Width and Height properties change when the UserForm is activated through the Activate method.

As you can see in Figure 3-6, the UserForm.Left and UserForm.Top properties control the initial UserForm position relative to the upper-left corner of the screen.



Vba Excel Userform Examples

Figure 3-6. The Top and Left properties of UserForm

Was this article helpful?

0 0


  • Sara
    How to change userform name in vba autocad?
    6 years ago
  • belinda
    How Add the AcFocusCtrl to the Toolbox in vba?
    6 years ago

Post a comment