Create Custom Userform Controls

You can customize the Toolbox window to suit your needs. The Toolbox that displays when you select a UserForm within the Visual Basic Editor contains all of the standard controls you can add to the UserForm. These controls display on a single tabbed page called Controls. You can change the icon that a control uses as well as the tip text that displays when you drag you cursor across the icon. You can also create new controls to add to the Toolbox.

add an OK button to all of your UserForms, you can create a custom button and set the appropriate properties such as the Caption, Width, Height, and Default. After you create the button, you place it on the Toolbox and the Visual Basic Editor adds it as a new control. After you add your new button to the Toolbox, you can select the Customize Control option and change its name and icon.

Making modifications to existing Toolbox controls is fairly straightforward. To modify an existing control, you access the Customize Control dialog box which enables you to change the text and load a new icon.

You create new controls by customizing and combining the existing controls on the Toolbox. For example, if you always

Alternately, you can create new controls by combining multiple controls. For example, you can create a new control that consists of both an OK and a Cancel button.

To keep your custom controls separate from the existing controls on the Toolbox, consider adding a new page to the Toolbox for your controls. You create a new page on the Toolbox using the New Page option.

CREATE CUSTOM USERFORM CONTROLS

View Insert Format Debug Run Tools Add-Ins Wind ii . al&isf&'g] g

Alphabetic | Categorized ]

Accelerator AutoSize False

^ ^

—n On the Toolbox, click the control you want to customize.

< On the Properties window, type the control name in the (Name) field.

^Q Type the text for the control in the Caption field.

Excel Control Toolbox
On the Toolbox, right click the Controls tab.

■ A menu displays the options available for the pages in the Toolbox.

Q Click New Page.

CUSTOMIZING DIALOG BOXES, MENUS, AND TOOLBARS

When you create your new page on the Toolbox, the Visual Basic Editor adds it as the second page on the Toolbox. To change the order of the pages, you can right-click the page tab, and click the Move option on the menu. Selecting this option displays the Move dialog box. To change the order of pages, click the desired page to select it, and click or F7 to indicate the direction you want to move the page.

Creating a separate page on the Toolbox to store your custom controls enables you to export the page for loading on another machine. To export the page of custom controls, right-click the page tab and click the Export Page option. In the Export Page dialog box, specify the name and location for the page file. The Visual Basics Editor assigns the page file an extension of .Pag indicating that it is a Toolbox page file.

You import a page file into the Toolbox by right-clicking the tab menu and clicking the Import Page option. In the Import Page dialog box, specify the name and location of the page file to import.

Excel 2000 Vba Userform

■ Drag the control to the Toolbox.

■ The new control appears on the new page of the Toolbox.

■ You can customize the name of the new control by right-clicking the control icon and clicking the control's Customizing option.

■ The Visual Basic Editor adds a new page to the Toolbox.

—H Click the control on the UserForm.

■ Drag the control to the Toolbox.

■ The new control appears on the new page of the Toolbox.

■ You can customize the name of the new control by right-clicking the control icon and clicking the control's Customizing option.

+6 -5

Responses

  • stefan
    How to change control in VBA?
    6 months ago
  • evelyn
    How to reference custom userform vba?
    6 months ago

Post a comment