Quote:
Originally Posted by Guessed
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
|
Thank you My dear .. this code works well , Also thank you for corrected the syntax error of my code ..
Quote:
Originally Posted by gmayor
Unless you want to retain every other table you need Step -1
This will leave the first table.
You could also modify the original code method to introduce a counter e.g.
Code:
Sub Removetables()
Dim oTable As Table
Dim i As Integer
i = 1
For Each oTable In ActiveDocument.Tables
If i > 1 Then oTable.Delete
i = i + 1
Next oTable
End Sub
Both methods are likely to leave empty paragraphs.
|
Thank you my dear .. your code works but it's deletes all tables accept the first one
Thanks for all once again
May God reward you