Count 属性

       

本主题中的某些内容可能不适用于某些语言。

返回或设置一个 Long 类型,表示指定集合中的项数。对于 BalloonCheckboxesBalloonLabels 对象为可读写 Long 类型,对于“应用于”列表中的所有其他对象为只读 Long 类型。

expression.Count

expression   必需。该表达式返回上面对象之一。

说明

对于 CommandBars 集合,该数目只包括菜单栏、工具栏和快捷菜单。

对于 Scripts 集合,返回的数目为指定文档中脚本块的数量。在 Microsoft Word 中,Scripts.Count 返回嵌入式和浮动脚本定位标记的总数。

示例

本示例使用 Count 属性显示 CommandBars 集合中命令栏的数量。

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

本示例使用 Count 属性显示“Office 助手”气球中复选框的数量。

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

本示例显示活动文档中自定义文档属性的数量。

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