Share via


DocumentBase.CountNumberedItems 方法

傳回文件中的分項或編號項目和 LISTNUM 欄位的數目。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public Function CountNumberedItems ( _
    ByRef numberType As Object, _
    ByRef level As Object _
) As Integer
public int CountNumberedItems(
    ref Object numberType,
    ref Object level
)

參數

  • level
    型別:System.Object%
    對應到要計算之編號方式層級的號碼。預設為計算所有層級。

傳回值

型別:System.Int32
文件中的分項或編號項目和 LISTNUM 欄位的數目。

備註

當您將 wdNumberParagraphwdNumberAllNumbers (預設值) 指定為 NumberType 時,就會計算分項項目。

有兩種數字型別:預設數字 (wdNumberParagraph),當您在 [項目符號及編號] 對話方塊中選取某一範本,就可以將這種數字型別加入至段落,LISTNUM 欄位 (wdNumberListNum),這種數字型別可讓您在每個段落中加入一個以上的數字。

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

範例

下列程式碼範例會使用 CountNumberedItems 方法,顯示文件中所有編號項目的數量。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentCountNumberedItems()
    Dim numCount As Integer = Me.CountNumberedItems( _
        Word.WdNumberType.wdNumberAllNumbers)
    MessageBox.Show(("Numbered items in this document: " + _
        numCount.ToString()))
End Sub
private void DocumentCountNumberedItems()
{
    object numberType = Word.WdNumberType.wdNumberAllNumbers;

    int numCount = this.CountNumberedItems(ref numberType, ref missing);
    MessageBox.Show("Numbered items in this document: " + 
        numCount.ToString());
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間