Count Property

Microsoft Office Object Model

Count Property

       

Some of the content in this topic may not be applicable to some languages.

Returns or sets a Long indicating the number of items in the specified collection. Read/write Long for the BalloonCheckboxes and BalloonLabels objects; read-only Long for all other objects in the Applies To list.

expression.Count

expression   Required. An expression that returns one of the above objects.

Remarks

For the CommandBars collection, the count includes only menu bars, toolbars, and shortcut menus.

For the Scripts collection, the count returned is the number of script blocks in the specified document. In Microsoft Word, Scripts.Count returns the total number of inline and floating script anchors combined.

Example

This example uses the Count property to display the number of command bars in the CommandBars collection.

MsgBox "There are " & CommandBars.Count & _
    " bars in the CommandBars collection."

This example uses the Count property to display the number of check boxes in the Office Assistant balloon.

With Assistant.NewBalloon
    .CheckBoxes(1).Text = "First Choice"
    .CheckBoxes(2).Text = "Second Choice"
    .Text = "You have the following " _
    & .CheckBoxes.Count & " choices."
    .Show
End With

This example displays the number of custom document properties in the active document.

MsgBox ("There are " & _
    ActiveDocument.CustomDocumentProperties.Count & _
    " custom document properties in the " & _
    "active document.")