convert table to text by columns

C

Crios

Hi
W XP SP3, MS Word 2003

I have a table with 2 rows (1,2) and 6 cols (A -> F) an I would like to
transform it into text by columns, i.e. each 2 cells from a column to appear
one after another:

A1, A2,
B1, B2, ...

instead of

A1, B1, C1, ....
A2, B2, ...

Thanx

Crios
 
G

Graham Mayor

Do you mean like
Table > Convert Table to Text separated by tabs
Table > Convert Text to Table > two columns
Table > Convert Table to Text > separated by commas?
which would give you

A1, A2

A3, A4

A5, A6

B1, B2

B3, B4

B5, B6



--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Crios

It's not working (see explanations).
What I want should do something like transpose from Excel, and then normal
convert Table to text


----- Original Message -----
From: "Graham Mayor" <[email protected]>
Newsgroups: microsoft.public.word.docmanagement
Sent: Monday, April 06, 2009 12:12
Subject: Re: convert table to text by columns
 
D

Doug Robbins - Word MVP on news.microsoft.com

If the table is the first table in the document and you run a macro
containing the following code when the cursor is in an empty paragraph
immediately after the table, it will arrange the text from the cells of the
table in the way that you want.

Dim i As Long, J As Long
Dim crange As Range
With ActiveDocument.Tables(1)
For J = 1 To .Columns.Count
For i = 1 To .Rows.Count - 1
Set crange = .Cell(i, J).Range
crange.End = crange.End - 1
Selection.InsertAfter crange.Text & vbTab
Next i
Set crange = .Cell(i + 1, J).Range
crange.End = crange.End - 1
Selection.InsertAfter crange.Text & vbCr
Next J
.Delete
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
C

Crios

Bottomline, it works.

Thanx


Doug Robbins - Word MVP on news.microsoft.com said:
If the table is the first table in the document and you run a macro
containing the following code when the cursor is in an empty paragraph
immediately after the table, it will arrange the text from the cells of
the table in the way that you want.

Dim i As Long, J As Long
Dim crange As Range
With ActiveDocument.Tables(1)
For J = 1 To .Columns.Count
For i = 1 To .Rows.Count - 1
Set crange = .Cell(i, J).Range
crange.End = crange.End - 1
Selection.InsertAfter crange.Text & vbTab
Next i
Set crange = .Cell(i + 1, J).Range
crange.End = crange.End - 1
Selection.InsertAfter crange.Text & vbCr
Next J
.Delete
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
G

Graham Mayor

It works for me!
Table > Convert Table to Text > separated by tabs
A1>B1>C1> D1>E1>F1
A2>B2>C2> D2>E2>F2
Table > Convert Text to Table > two columns
A1¦B1
C1¦D1
E1¦F1
A2¦B2
C2¦D2
E2¦F2
Table > Convert Table to Text > separated by commas
A1, B1
C1, D1
E1, F1
A2, B2
C2, D2
E2, F2

or by macro

ActiveDocument.Tables(1).Select
With Selection
.Rows.ConvertToText Separator:=wdSeparateByTabs
.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2
.Rows.ConvertToText Separator:=wdSeparateByCommas
End With

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Forget that - I think we are at cross purposes here :(

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top