Style Property

Applies To

CommandBarButton object, CommandBarComboBox object.

Description

CommandBarButton object: Returns or sets the way the specified command bar button control is displayed. Can be one of the following MsoButtonStyle constants: msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption. Read/write Long.

CommandBarComboBox object: Returns or sets the way the specified command bar combo box control is displayed. Can be either of the following MsoComboStyle constants: msoComboLabel or msoComboNormal. Read/write Long.

Specifics (Microsoft Access)

In Microsoft Access 97, you can use the Toolbar Control Properties dialog box for command bar controls to set the display style for a button 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 Style 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. Select the style you want in the Style box.

The settings in the Style box correspond to the intrinsic constants used as the setting of the Style property in the following way.

Style box setting

Style property constant

Default Style

msoButtonAutomatic

Text Only (Always)

msoButtonCaption

Text Only (in Menus)

msoButtonIcon

Image and Text

msoButtonIconAndCaption

No Label

msoComboNormal

Show Label

msoComboLabel


Example

This example creates a shortcut menu containing a button control and a combo box control and sets the style of each.

Set myBar = CommandBars _
    .Add(Name:="Custom1", Position:=msoBarPopup, Temporary:=False)
With myBar
    .Controls.Add Type:=msoControlButton, Id:=3
    .Controls(1).Style = msoButtonCaption
    .Controls.Add Type:=msoControlComboBox
    With .Controls(2)
        .Style = msoComboLabel
        .AddItem "vanilla"
        .AddItem "chocolate"
        .AddItem "cookie dough"
    End With
End With
myBar.ShowPopup