Publisher) (Rows 物件

一組 資料列 代表表格中的列的物件。

註解

使用 Table 物件的 Rows 屬性傳回 Rows 集合。

使用 [列] (索引) ,其中 index 是索引號碼,以傳回單一 Row 物件。 索引編號代表 Rows 集合 (從左到右統計) 中之列的位置。

範例

下列範例會顯示使用中文件第一個表格之 Rows 集合中的 Row 物件數目。

Sub CountRows() 
 MsgBox ActiveDocument.Pages(2).Shapes(1).Table.Rows.Count 
End Sub

此範例會設定所有偶數列的填滿,並清除指定資料表中所有奇數列的填滿。 此範例假設指定的圖形是表格,而不是其他類型的圖形。

Sub FillCellsByRow() 
 Dim shpTable As Shape 
 Dim rowTable As Row 
 Dim celTable As Cell 
 
 Set shpTable = ActiveDocument.Pages(2).Shapes(1) 
 For Each rowTable In shpTable.Table.Rows 
 For Each celTable In rowTable.Cells 
 If celTable.Row Mod 2 = 0 Then 
 celTable.Fill.ForeColor.RGB = RGB _ 
 (Red:=180, Green:=180, Blue:=180) 
 Else 
 celTable.Fill.ForeColor.RGB = RGB _ 
 (Red:=255, Green:=255, Blue:=255) 
 End If 
 Next celTable 
 Next rowTable 
 
End Sub

下列範例會選取指定表格中的第三列。

Sub SelectRows() 
 ActiveDocument.Pages(2).Shapes(1).Table.Rows(3).Cells.Select 
End Sub

方法

屬性

另請參閱

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。