Reputation: 519
I'd like to build a macro that selects every table in a document, appends a row and sets the value of the first cell in that row to "Text".
Here is what I have now:
Sub AddProofRow()
Dim t As Table
For Each t In ActiveDocument.Tables
t.Rows.Add
NewRow = t.Rows.Last
NewRow.Cells(t.Rows.Count, 1).Value = "Proof"
Next
End Sub
But, I get errors when I run it, how can I make this work?
Upvotes: 1
Views: 1358
Reputation: 14373
Please try this code.
Sub AppendRowWithText()
' 24 Apr 2017
Dim NewRow As Row
Dim t As Integer
With ActiveDocument
For t = 1 To .Tables.Count
Set NewRow = .Tables(t).Rows.Add
NewRow.Cells(1).Range.InsertAfter Text:="Text"
Next t
End With
End Sub
Upvotes: 1