Count Property

Microsoft Office Visual Basic

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 Permission object, the Count property returns 0 (zero) if permissions are not enabled on the active document. When permissions are enabled, the Count property always returns at least 1, representing the permissions of the document author.

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.")