Thread: [Solved] table removal syntax
View Single Post
 
Old 01-22-2015, 08:50 PM
Guessed's Avatar
Guessed Guessed is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You need to work backwards since the act of deleting a table reduces the number of tables in the document.
Sub RemoveTables2()
Dim i As Integer
For i = ActiveDocument.Tables.Count To 2 Step -2
ActiveDocument.Tables(i).Delete
Next i
End Sub

PS. The code you posted is erroring because you are missing the word 'For' in the front of the 'Each ...' line
Reply With Quote