Delete Everything EXCEPT Items in a Table

R

ryguy7272

Does anyone have a macro that will delete everything in a word document
EXCEPT items in a table?

Thanks,
Ryan---
 
G

Greg Maxey

Ok. Again provided that each table is separated by at least one empty
paragraph (otherwise all tables will be joined as one big table) then:

Sub Test()
Dim oPar As Paragraph
For Each oPar In ActiveDocument.Range.Paragraphs
If Not oPar.Range.Information(wdWithInTable) And Len(oPar.Range.Text) > 1
Then
oPar.Range.Delete
End If
Next
End Sub
 
R

ryguy7272

Got it!
Sub DelNonTables()
Dim myPara As Paragraph
For Each myPara In ActiveDocument.Paragraphs
If Not myPara.Range.Information(wdWithInTable) Then
myPara.Range.Delete
End If
Next

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