Automatically Removing Empty Nested Tables

R

Robert

Hi all,

I was wondering if anyone could help me with a macro. I am
implementing a macro that I found awhile ago written by Lene Fredborg
that automatically removes empty tables. This macro works well with
first level tables but does not work on nested tables. I'm not so
well versed in VBA so after trying multiple times to alter the code, I
have come to a standstill. If anyone could help me with automating
the process of removing empty nested tables from a document, it would
be much appreciated.

The original macro for first level tables is as follows:

Sub DeleteEmptyRows_AllTables()

Dim oTable As Table
Dim oRow As Row

For Each oTable In ActiveDocument.Tables
For Each oRow In oTable.Rows
'Check whether row is empty - delete if it is
If Len(oRow.Range.Text) = oRow.Cells.Count * 2 + 2 Then
oRow.Delete
End If
Next oRow
Next oTable

End Sub

Cheers.
 
N

nelsonferro

Hello Robert, have you found a answer to your question? I have the same problem i can't find the answer anywhere.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top