Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dhruva81/cb919389a535dcfdc5e00beefecb34fb to your computer and use it in GitHub Desktop.

Select an option

Save dhruva81/cb919389a535dcfdc5e00beefecb34fb to your computer and use it in GitHub Desktop.
Insert a New Row at Top/Bottom of Tables in MS Word using VBA
Sub insertTopRow()
Dim theTable As Table
Dim theNewRow As Row
Dim i As Integer
For i = 1 to ActiveDocument.Tables.Count
Set theTable = ActiveDocument.Tables(i)
Set theNewRow = theTable.Rows.Add(theTable.Rows.First)
'Other row formatting
Next i
End Sub
Sub insertBottomRow()
Dim theTable As Table
Dim theNewRow As Row
Dim i As Integer
For i = 1 to ActiveDocument.Tables.Count
Set theTable = ActiveDocument.Tables(i)
Set theNewRow = theTable.Rows.Add
'Other row formatting
Next i
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment