Count 属性

       

返回指定集合的项目数。Long 类型,只读。

expression.Count

expression   必需。该表达式返回“应用于”列表中的一个对象。

示例

本示例显示活动文档的段数。

MsgBox "The active document contains " & _
    ActiveDocument.Paragraphs.Count  & "paragraphs."

本示例显示所选内容的字数。

If Selection.Words.Count >= 1 And _
        Selection.Type <> wdSelectionIP Then
    MsgBox "The selection contains " & Selection.Words.Count _
        & " words."
End If

本示例用一个 Fields() 数组来储存活动文档中的域代码。

fcount = ActiveDocument.Fields.Count
If fcount >= 1 Then
    ReDim aFields(fcount)
    For Each aField In ActiveDocument.Fields
        aFields(aField.Index) = aField.Code.Text
    Next aField
End If