次の方法で共有


DocumentBase.Tables プロパティ

文書内のすべての表を表す Tables コレクションを取得します。

名前空間:  Microsoft.Office.Tools.Word
アセンブリ:  Microsoft.Office.Tools.Word.v4.0.Utilities (Microsoft.Office.Tools.Word.v4.0.Utilities.dll 内)

構文

'宣言
Public ReadOnly Property Tables As Tables
    Get
public Tables Tables { get; }

プロパティ値

型: Microsoft.Office.Interop.Word.Tables
文書内のすべての表を表す Tables コレクション。

文書に新しい表を追加し、各セルに、そのセルの前にあるセルの数値をインクリメントして設定するコード例を次に示します。 この例を使用するには、これをドキュメント レベルのプロジェクトの ThisDocument クラスから実行します。

Private Sub DocumentTables()
    Me.Paragraphs(1).Range.InsertParagraphAfter()

    Dim table1 As Word.Table = Me.Tables.Add(Me.Application.Selection.Range, 4, 2)

    Dim cellNumber As Integer = 1
    Dim rowCount As Integer
    For rowCount = 1 To table1.Rows.Count
        Dim columnCount As Integer
        For columnCount = 1 To table1.Columns.Count
            table1.Rows(rowCount).Cells(columnCount).Range.Text = cellNumber.ToString()
            cellNumber += 1
        Next columnCount
    Next rowCount

End Sub 
private void DocumentTables()
{
    this.Paragraphs[1].Range.InsertParagraphAfter();

    Word.Table table1 = this.Tables.Add(
        this.Application.Selection.Range,
        4, 2, ref missing, ref missing);

    int cellNumber = 1;
    for (int rowCount = 1; rowCount <= table1.Rows.Count;
        rowCount++)
    {
        for (int columnCount = 1; columnCount <= table1.Columns.Count;
            columnCount++)
        {
            table1.Rows[rowCount].Cells[columnCount].Range.Text =
                cellNumber.ToString();
            cellNumber++;
        }
    }
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

DocumentBase クラス

Microsoft.Office.Tools.Word 名前空間