Macro to find and delete specific table

S

Sammy

Hello,

We have a one-row, blank table appearing at the bottom of page 1 in hundreds
of documents (it is not in the footer). This was due to a conversion utility
that was used on these docs. Anyway, I need to create a macro that searches
the doc for this table but I can't use a specific table number in the tables
collection because there may be other legitimate tables in some of the
documents, either before or after the blank table. So, I need find the
one-row blank table and delete it.

Any ideas? Your time is always appreciated.
 
F

fumei via OfficeKB.com

Is it the ONLY one row table? Are there many of them? Are there any
legitimate one row blank tables?

If there are NO legitimate one row tables - i.e you want to remove all one
row tables - then:

Dim aTable As Table
For Each aTable In ActiveDocument.Tables
If aTable.Rows.Count = 1 Then
aTable.Delete
End If
Next

will delete all one row tables.
 
S

Sammy

This works wonderfully, thanks.

fumei via OfficeKB.com said:
Is it the ONLY one row table? Are there many of them? Are there any
legitimate one row blank tables?

If there are NO legitimate one row tables - i.e you want to remove all one
row tables - then:

Dim aTable As Table
For Each aTable In ActiveDocument.Tables
If aTable.Rows.Count = 1 Then
aTable.Delete
End If
Next

will delete all one row tables.
 

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