PDA

View Full Version : Convert table to text with delimiters



translator_
10-09-2012, 11:08 AM
I want to convert a two column table to text and add some delimiters with a specific style (tw4winMark) at the beginning of each row, the middle of the row, and the end of the row. So that this:

Left cell 1|Right cell 1
Left cell 2|Right cell 2

Will become this:

{0>Left cell 1<}0{>Right cell 1<0}
{0>Left cell 2<}0{>Right cell 2<0}

Now, I have gone as far as converting the table to text, but I have some trouble adding the delimiters with the style and making sure that the paragraph mark does not acquire the special style:

Sub ConvertTabletotext()
If Selection.Information(wdWithInTable) = True Then
Selection.Tables(1).ConvertToText Separator:=wdSeparateByTabs
Else
MsgBox "Move the insertion point in the table."
End If
End Sub

Demo content, style and steps in attachment.

fumei
10-09-2012, 04:00 PM
That is very bizarre behaviour. The hidden Left cell 1 is hidden, but it is Normal. How very strange. I am trying to duplicate the behaviour.

translator_
10-10-2012, 12:00 AM
If you are talking about the third instance (of the desired result) this is part of the style (it will hide the ex-left column text). But you need not worry about that really :)