Caption Property

Applies To

CommandBarButton object, CommandBarComboBox object, CommandBarControl object, CommandBarPopup object.

Description

Returns or sets the caption text for the specified command bar control. Read/write String.

Note The caption for a control is also displayed as its default ScreenTip.

See Also

Add method (CommandBarControls collection), CommandBarControl object, DescriptionText property, Enabled property, TooltipText property.

Specifics (Microsoft Access)

In Microsoft Access 97, you can use the Toolbar Control Properties dialog box for command bar controls to set the caption for a control on a command bar. Display the Customize dialog box by pointing to Toolbars on the View menu and clicking Customize. For menu bar and toolbar controls, display the menu bar or toolbar, and then right-click the control whose Caption property you want to set. For shortcut menu controls, select the Shortcut Menus check box on the Toolbars tab of the Customize dialog box, then find the shortcut menu control you want on the menu bar that's displayed and right-click the control. Click the Properties command. Enter the caption you want in the Caption box.

When you display a control's Caption property setting in the Toolbar Control Properties dialog box or in Visual Basic, the ampersand (&) for the accelerator key is displayed (for example, &Paste). When you reference the control in Visual Basic, you can choose to include the ampersand (or not). For example, the following references are identical:

CommandBars("Menu Bar").Controls("Tools")
CommandBars("Menu Bar").Controls("&Tools")
When setting the Caption property, you must include the ampersand if you want the control to have an accelerator key.

Example

This example adds a command bar control with a spelling checker button face to a custom command bar, and then it sets the caption to "Spelling checker."

Set myBar = CommandBars.Add(Name:="Custom", _
    Position:=msoBarTop, Temporary:=True)
myBar.Visible = True
Set myControl = myBar.Controls.Add(Type:=msoControlButton, Id:=2)
With myControl
    .DescriptionText = "Starts the spelling checker"
    .Caption = "Spelling checker"
End With