Greg
This is a very interesting example of a recursive function to return a collection. I'm intrigued that it works to build a collection which appears to be recreated from New with each recursion. I'm going to have to study this to work how you did that. I would have expected the collection to be created in the Sub and then passed in to the function for filling.
On a speed front, I would think that looping through all the tables appears to be less efficient than just searching for the text and then checking if it happens to be in a nested table. Would this code not do the same thing without the recursion?
Code:
Sub FlyTheNest()
Dim aRng As Range
Set aRng = ActiveDocument.Range
With aRng.Find
.ClearFormatting
.Text = "XXX text"
.Forward = True
.Wrap = wdFindStop
.Format = False
While .Execute
'aRng.Select 'testing purposes only
If aRng.Information(wdWithInTable) Then
If aRng.Tables(1).NestingLevel > 1 Then
aRng.Rows(1).Delete
End If
End If
Wend
End With
End Sub