PDA

View Full Version : Macro to convert table to text



sujittalukde
12-21-2007, 12:37 AM
I am copying and pasting the forum replies in Word and the same are pasted in a word document. these are pasted in the forms of table. Now I am manually selecting the tables and then go to menu Table\Convert\TabletoText to convert the table format into text.
This reduces the extra spaces and thus needs less paper to get the print out.
This manual conversion is very lenghty and consumes huge time.

Can someone help me to provide a macro to do the same. I tried to do the same by recording a macro but here the problem is that it doesnot work for all the tables in the document.

fumei
12-21-2007, 02:06 PM
It may help if you posted a sample of a document.

"these are pasted in the forms of table. "

Why are they pasted in the forms of table, especially when you are - it seems - wanting them NOT in tables.

Why not paste them not in a table in the first place?

sujittalukde
12-21-2007, 10:02 PM
Thanks for the reply. I have attached the one zip file containing two documents. One is Original document after teh pasting of copied elemts and the next one is the desired output.
Directly pasting the same not in table format requires more time and lengthy process so I directlt paste the same as it is basis and thus pasted in tables

Tinbendr
02-14-2008, 12:29 PM
Sub ConvertTables()
'Word 2003
Dim aDoc As Document
Dim Rng As Range
Dim EachTable As Table
Set aDoc = ActiveDocument
For Each EachTable In aDoc.Tables
With EachTable
'Add a tab after the username
Set Rng = EachTable.Cell(1, 1).Range.Words(1)
Rng.Collapse wdCollapseEnd
Rng.InsertAfter Chr(9)
'Convert Table to text
.ConvertToText
End With
Next

End Sub

fumei
02-15-2008, 10:51 AM
Tinbendr, nice. Although VERY tied to the specific structure of the given sample original tables. Hopefully they are indeed all that way.

sujittalukde, are you aware that those double lines are InlineShapes drawing objects? You would be better off having them as simple paragraphs, with the format set by a Style.