![]() |
|
#5
|
||||
|
||||
|
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
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
| Tags |
| nested table, search nested table |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Formatting Nested Tables | LBruce | Word VBA | 3 | 01-20-2020 09:07 AM |
Delete all empty rows in all tables
|
fbucaram | Word VBA | 6 | 01-05-2018 03:04 PM |
| Nested tables. Count rows | NevilleT | Word VBA | 9 | 05-10-2017 05:22 AM |
Macro to delete all empty rows from all tables
|
braddgood | Word VBA | 15 | 10-02-2015 01:54 PM |
| Nested vlookup with varable tables! | Dave Jones | Excel | 0 | 08-30-2012 09:15 AM |