Reputation: 23
In Microsoft Word 2010, I have the following macro working quite well in my form. After the new row is added I need it to have the new row with predefined text added to column 1, 2 and 3. In Column 2, I need to have multiple lines inside the same row. The Table has only 3 columns. How would I do this?
Sub addrow()
Dim oTable As Table
Dim oCell As Cell
Dim oPrevRow As Row, oNewRow As Row
Dim iColumn As Long
' Insert new row
Set oTable = ActiveDocument.Tables(3)
Set oPrevRow = oTable.Rows(oTable.Rows.count)
oTable.Rows.Add
Set oNewRow = oTable.Rows(oTable.Rows.count)
End Sub
Upvotes: 1
Views: 20853
Reputation: 33476
Set oNewRow = oTable.Rows(oTable.Rows.count)
oNewRow.Cells(1).Range.Text = "Column 1 Text"
oNewRow.Cells(2).Range.Text = "Column 2 Text"
oNewRow.Cells(3).Range.Text = "Column 3 Text"
Upvotes: 3