The method to delete all the THead elements except one is:
Dim intIndex As Integer
intIndex = 0
For i = ActiveDocument.all.tags("table"). _
Item(0).Children.tags("thead").Length - 1 _
To 0 Step -1
If i <> intIndex Then
ActiveDocument.all.tags("table"). _
Item(0).Children.tags("thead"). _
Item(i).outerHTML = ""
End If
Next i
The method above will delete all THead elements except for the first one.
The method below will delete all TFoot elements except for the first one.
Dim intIndex As Integer
intIndex = 0
For i = ActiveDocument.all.tags("table"). _
Item(0).Children.tags("tfoot").Length - 1 _
To 0 Step -1
If i <> intIndex Then
ActiveDocument.all.tags("table"). _
Item(0).Children.tags("tfoot"). _
Item(i).outerHTML = ""
End If
Next i
The method below will delete only one body element. In the example below it will delete the second body element.
Dim intIndex As Integer
intIndex = 1
For i = ActiveDocument.all.tags("table"). _
Item(0).Children.tags("tbody").Length - 1 _
To 0 Step -1
If i = intIndex Then
ActiveDocument.all.tags("table"). _
Item(0).Children.tags("tbody"). _
Item(i).outerHTML = ""
End If
Next i