State Property

Microsoft Office Visual Basic

Returns or sets the appearance of a command bar button control. Read/write MsoButtonState. However the State property of built-in command bar buttons is read-only.

MsoButtonState can be one of these MsoButtonState constants.
msoButtonDown
msoButtonMixed
msoButtonUp

expression.State

expression    Required. An expression that returns a CommandBarButton object.

ShowState property as it applies to the HTMLProject object.

Returns the current state of an HTMLProject object. Read-only MsoHTMLProjectState.

MsoHTMLProjectState can be one of these MsoHTMLProjectState constants.
msoHTMLProjectStateDocumentLocked
msoHTMLProjectStateDocumentProjectUnlocked
msoHTMLProjectStateProjectLocked

expression.State

expression    Required. An expression that returns an HTMLProject object.

Example

ShowAs it applies to the CommandBarButton object.

This example creates a command bar named Custom and adds two buttons to it. The example then sets the button on the left to msoButtonUp and sets the button on the right to msoButtonDown.

    Dim myBar As Office.CommandBar
    Dim imgSource As Office.CommandBarButton
    Dim myControl1 As Office.CommandBarButton
    Dim myControl2 As Office.CommandBarButton
    ' Add new command bar.
    Set myBar = CommandBars.Add(Name:="Custom", Position:=msoBarTop, Temporary:=True)
    ' Add 2 buttons to new command bar.
    With myBar
        .Controls.Add Type:=msoControlButton
        .Controls.Add Type:=msoControlButton
        .Visible = True
    End With
    ' Paste Bold button face and set State of first button.
    Set myControl1 = myBar.Controls(1)
    Set imgSource = CommandBars.FindControl(msoControlButton, 113)
    imgSource.CopyFace
    With myControl1
        .PasteFace
        .State = msoButtonUp
    End With
    ' Paste Italics button face and set State of second button.
    Set myControl2 = myBar.Controls(2)
    Set imgSource = CommandBars.FindControl(msoControlButton, 114)
    imgSource.CopyFace
    With myControl2
        .PasteFace
        .State = msoButtonDown
    End With