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

Applies to | AnswerWizardFiles Collection Object | BalloonCheckBoxes Collection Object | BalloonLabels Collection Object | COMAddIns Collection Object | CommandBarControls Collection Object | CommandBars Collection Object | DocumentLibraryVersions Collection | DocumentProperties Collection Object | FileDialogFilters Collection | FileDialogSelectedItems Collection | FileTypes Collection | FoundFiles Object | HTMLProjectItems Collection | ODSOColumns Object | ODSOFilters Object | Permission Object | PropertyTests Collection Object | ScopeFolders Collection | Scripts Collection Object | SearchFolders Collection | SearchScopes Collection | SharedWorkspaceFiles Collection | SharedWorkspaceFolders Collection | SharedWorkspaceLinks Collection | SharedWorkspaceMembers Collection | SharedWorkspaceTasks Collection | SignatureSet Collection | WebPageFonts Collection Object