Rows.Add method (Word)
Returns a Row object that represents a row added to a table.
expression.Add ( _BeforeRow_
)
expression Required. A variable that represents a Rows object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
BeforeRow | Optional | Variant | A Row object that represents the row that will appear immediately below the new row. |
Row
This example inserts a new row before the first row in the selection.
Sub AddARow()
If Selection.Information(wdWithInTable) = True Then
Selection.Rows.Add BeforeRow:=Selection.Rows(1)
End If
End Sub
This example adds a row to the first table and then inserts the text Cell into this row.
Sub CountCells()
Dim tblNew As Table
Dim rowNew As Row
Dim celTable As Cell
Dim intCount As Integer
intCount = 1
Set tblNew = ActiveDocument.Tables(1)
Set rowNew = tblNew.Rows.Add(BeforeRow:=tblNew.Rows(1))
For Each celTable In rowNew.Cells
celTable.Range.InsertAfter Text:="Cell " & intCount
intCount = intCount + 1
Next celTable
End Sub
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.