Remove Table but keep Content: Word 2003/2007
Remove Table but keep Content: Word 2003/2007
(OP)
Hello Champs
Is there a way to remove tables from a word document but keeping the content of each row by using VBA?
The Table isnt complext, simple rows (one coloumn) only.
Number of rows varies from 1-10 per table, multiple tables.
Problem: I cant use copy/paste plain text, as the content contains encoded URLs displayed as textlink.
Any hint?
Is there a way to remove tables from a word document but keeping the content of each row by using VBA?
The Table isnt complext, simple rows (one coloumn) only.
Number of rows varies from 1-10 per table, multiple tables.
Problem: I cant use copy/paste plain text, as the content contains encoded URLs displayed as textlink.
Any hint?

Talk To Other Members
RE: Remove Table but keep Content: Word 2003/2007
CODE
For Each oTable In ActiveDocument.Tables
oTable.Rows.ConvertToText Separator:=wdSeparateByParagraphs, _
NestedTables:=True
Next
Hyperlinks are retained exactly as they are. They are not affected in any way.
Gerry
My paintings and sculpture
RE: Remove Table but keep Content: Word 2003/2007
It really works incredebly fast!
Do you also know a method to delete the last two coloumns of the table prior removing the table and converting the containing text as per your above sample?
RE: Remove Table but keep Content: Word 2003/2007
CODE
Dim j As Long
For Each oTable In ActiveDocument.Tables
j = oTable.Rows.Count
oTable.Rows(j).Delete
oTable.Rows(j - 1).Delete
oTable.Rows.ConvertToText Separator:=wdSeparateByParagraphs, _
NestedTables:=True
Next
There are, like many things in VBA, alternative ways to do this. You could select the last two rows, then delete. You could make a Range of the last two rows, then delete. However, I think using the row count is probably the easiest.
Gerry
My paintings and sculpture
RE: Remove Table but keep Content: Word 2003/2007
frankki,
Again, using your macro recorder would have given you a start on this one too.
Skip,
![[tongue] tongue](https://www.tipmaster.com/images/tongue.gif)
RE: Remove Table but keep Content: Word 2003/2007
Gerry
My paintings and sculpture