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
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 보안
- 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.