Document.Tables, propriété (System 2007)

Mise à jour : novembre 2007

Obtient une collection Tables qui représente toutes les tables dans le document.

Espace de noms :  Microsoft.Office.Tools.Word
Assembly :  Microsoft.Office.Tools.Word.v9.0 (dans Microsoft.Office.Tools.Word.v9.0.dll)

Syntaxe

<BrowsableAttribute(False)> _
Public ReadOnly Property Tables As Tables

Dim instance As Document
Dim value As Tables

value = instance.Tables
[BrowsableAttribute(false)]
public Tables Tables { get; }

Valeur de propriété

Type : Microsoft.Office.Interop.Word.Tables

Collection Tables qui représente toutes les tables dans le document.

Exemples

L'exemple de code suivant ajoute une nouvelle table au document et remplit chaque cellule avec un nombre qui est incrémenté du nombre de la cellule précédente.

Cet exemple illustre une personnalisation au niveau du document.

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++;
        }
    }
}

Autorisations

Voir aussi

Référence

Document, classe

Membres Document

Microsoft.Office.Tools.Word, espace de noms