Globally removing certain tables in a document

T

Tamara

I have a certain number of tables in my document that I want to remove. They
are scattered throughout the document. The text in the tables is colored red.
If I write a macro to globally find & replace red text with nothing, it
removes the text but not the tables themselves (i.e., I end up with a bunch
of empty tables). How can I automate this process so that I can remove these
tables?
 
J

Jay Freedman

Tamara said:
I have a certain number of tables in my document that I want to
remove. They are scattered throughout the document. The text in the
tables is colored red. If I write a macro to globally find & replace
red text with nothing, it removes the text but not the tables
themselves (i.e., I end up with a bunch of empty tables). How can I
automate this process so that I can remove these tables?

Use this macro (see http://www.gmayor.com/installing_macro.htm if needed):

Sub KillRedTables()
Dim oTbl As Table

For Each oTbl In ActiveDocument.Tables
If oTbl.Cell(1, 1).Range.Font.Color = wdColorRed Then
oTbl.Delete
End If
Next oTbl
End Sub
 

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