Rows object (Publisher)

A collection of Row objects that represent the rows in a table.

Remarks

Use the Rows property of the Table object to return the Rows collection.

Use Rows (index), where index is the index number, to return a single Row object. The index number represents the position of the row in the Rows collection (counting from left to right).

Example

The following example displays the number of Row objects in the Rows collection for the first table in the active document.

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

This example sets the fill for all even-numbered rows, and clears the fill for all odd-numbered rows in the specified table. This example assumes that the specified shape is a table and not another type of shape.

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

The following example selects the third row in the specified table.

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

Methods

Properties

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.