A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Two rows per row?



 
 
Thread Tools Display Modes
  #1  
Old December 19th, 2006, 08:01 PM posted to microsoft.public.word.tables
Ed Sheehan
external usenet poster
 
Posts: 14
Default Two rows per row?

I have a bunch of rows with every other row terminated by a CR. The previous
row is terminated by a manual line break. Can I convert text to table and
have the two rows occupy one table row, with the end of the first row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure how to
terminate here
|This is the second text row | Still second | before conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed


  #2  
Old December 19th, 2006, 08:14 PM posted to microsoft.public.word.tables
Suzanne S. Barnhill
external usenet poster
 
Posts: 31,786
Default Two rows per row?

I think what you're asking is whether you can create a two-column table out
of two-line text paragraphs, separating at the line break. I suspect not.
Replace the line break (^l) with a paragraph break (^p) and then convert
text to table, separating at paragraph breaks, but forcing a two-column
table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Ed Sheehan" wrote in message
...
I have a bunch of rows with every other row terminated by a CR. The

previous
row is terminated by a manual line break. Can I convert text to table and
have the two rows occupy one table row, with the end of the first row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure how to
terminate here
|This is the second text row | Still second | before

conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed



  #3  
Old December 19th, 2006, 08:29 PM posted to microsoft.public.word.tables
Ed Sheehan
external usenet poster
 
Posts: 14
Default Two rows per row?

What I an trying for is to flow two text rows into one table row. I already
have 4 columns defined via embedded tabs. It's just that the two rows are
related so I want them in their own table rows.

So if I have 100 text rows, I would end up with 50 table rows, each with two
rows of text inside, for all 4 columns.

Sorry if I'm explaining this badly.

Ed

"Suzanne S. Barnhill" wrote in message
...
I think what you're asking is whether you can create a two-column table out
of two-line text paragraphs, separating at the line break. I suspect not.
Replace the line break (^l) with a paragraph break (^p) and then convert
text to table, separating at paragraph breaks, but forcing a two-column
table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
I have a bunch of rows with every other row terminated by a CR. The

previous
row is terminated by a manual line break. Can I convert text to table and
have the two rows occupy one table row, with the end of the first row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure how to
terminate here
|This is the second text row | Still second | before

conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed





  #4  
Old December 19th, 2006, 09:37 PM posted to microsoft.public.word.tables
Suzanne S. Barnhill
external usenet poster
 
Posts: 31,786
Default Two rows per row?

In other words, you basically have a table created with tabs, as follows:

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

There's undoubtedly a way to do this programmatically, but I think I would
be inclined to start by converting to a four-column table, separating at
tabs. If the line breaks cause an issue, convert them to paragraph breaks
first. Then merge cells vertically to group each pair of entries, using F4
to repeat the operation. Or create the groups visually using line spacing
and application or omission of cell borders.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Ed Sheehan" wrote in message
...
What I an trying for is to flow two text rows into one table row. I

already
have 4 columns defined via embedded tabs. It's just that the two rows are
related so I want them in their own table rows.

So if I have 100 text rows, I would end up with 50 table rows, each with

two
rows of text inside, for all 4 columns.

Sorry if I'm explaining this badly.

Ed

"Suzanne S. Barnhill" wrote in message
...
I think what you're asking is whether you can create a two-column table

out
of two-line text paragraphs, separating at the line break. I suspect

not.
Replace the line break (^l) with a paragraph break (^p) and then convert
text to table, separating at paragraph breaks, but forcing a two-column
table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
I have a bunch of rows with every other row terminated by a CR. The

previous
row is terminated by a manual line break. Can I convert text to table

and
have the two rows occupy one table row, with the end of the first row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure how

to
terminate here
|This is the second text row | Still second | before

conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed






  #5  
Old December 19th, 2006, 10:35 PM posted to microsoft.public.word.tables
Lene Fredborg
external usenet poster
 
Posts: 1,294
Default Two rows per row?

I understood the explanation in the same way as explained by Suzanne in the
latest post. If this is correct, I think that the macro below will convert
your text to a table the way you want.

Copy the macro and paste it into your Visual Basic editor. Before executing
it, you must select _all_ the text you want to include in the table.

The macro converts the text to a table with 4 columns (separated by your
tabs). Then it merges cells two and two in order to have your two related
lines inserted in the same table cell. You may need to change table borders,
column widths, etc. afterwards.

Sub ConvertToTable()
Dim oTable As Table
Dim n As Long
Dim i As Long

Set oTable = Selection.ConvertToTable(Separator:=vbTab, numcolumns:=4)
With oTable
For n = 1 To .Rows.Count / 2
For i = 1 To 4
.Cell(n, i).Range.Select
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Cells.Merge
Next i
Next n
.Cell(1, 1).Select
End With
set otable = nothing
End Sub

--
Regards
Lene Fredborg
DocTools – Denmark
www.thedoctools.com
Document automation – add-ins, macros and templates for Microsoft Word


"Suzanne S. Barnhill" wrote:

In other words, you basically have a table created with tabs, as follows:

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

There's undoubtedly a way to do this programmatically, but I think I would
be inclined to start by converting to a four-column table, separating at
tabs. If the line breaks cause an issue, convert them to paragraph breaks
first. Then merge cells vertically to group each pair of entries, using F4
to repeat the operation. Or create the groups visually using line spacing
and application or omission of cell borders.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Ed Sheehan" wrote in message
...
What I an trying for is to flow two text rows into one table row. I

already
have 4 columns defined via embedded tabs. It's just that the two rows are
related so I want them in their own table rows.

So if I have 100 text rows, I would end up with 50 table rows, each with

two
rows of text inside, for all 4 columns.

Sorry if I'm explaining this badly.

Ed

"Suzanne S. Barnhill" wrote in message
...
I think what you're asking is whether you can create a two-column table

out
of two-line text paragraphs, separating at the line break. I suspect

not.
Replace the line break (^l) with a paragraph break (^p) and then convert
text to table, separating at paragraph breaks, but forcing a two-column
table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
I have a bunch of rows with every other row terminated by a CR. The
previous
row is terminated by a manual line break. Can I convert text to table

and
have the two rows occupy one table row, with the end of the first row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure how

to
terminate here
|This is the second text row | Still second | before
conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed







  #6  
Old December 19th, 2006, 10:40 PM posted to microsoft.public.word.tables
Ed Sheehan
external usenet poster
 
Posts: 14
Default Two rows per row?

Yeah, I was hoping to avoid going thru those steps 1,500 times. Since one
can merely press Enter in a cell to create an embedded new row, I thought
there might be a tag or something I could embed to create the same effect in
conversion. But, I guess not. Also, if you do it manually, then convert
table to text, then text to table, you'll lose the groupings, so Word
doesn't preserve that info thru the conversion procedure either.

I may need to rethink the double row deal and maybe scrunch it together on
the same row.

Thanks for your help,

Ed


"Suzanne S. Barnhill" wrote in message
...
In other words, you basically have a table created with tabs, as follows:

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

There's undoubtedly a way to do this programmatically, but I think I would
be inclined to start by converting to a four-column table, separating at
tabs. If the line breaks cause an issue, convert them to paragraph breaks
first. Then merge cells vertically to group each pair of entries, using F4
to repeat the operation. Or create the groups visually using line spacing
and application or omission of cell borders.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
What I an trying for is to flow two text rows into one table row. I

already
have 4 columns defined via embedded tabs. It's just that the two rows are
related so I want them in their own table rows.

So if I have 100 text rows, I would end up with 50 table rows, each with

two
rows of text inside, for all 4 columns.

Sorry if I'm explaining this badly.

Ed

"Suzanne S. Barnhill" wrote in message
...
I think what you're asking is whether you can create a two-column table

out
of two-line text paragraphs, separating at the line break. I suspect

not.
Replace the line break (^l) with a paragraph break (^p) and then
convert
text to table, separating at paragraph breaks, but forcing a two-column
table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
I have a bunch of rows with every other row terminated by a CR. The
previous
row is terminated by a manual line break. Can I convert text to table

and
have the two rows occupy one table row, with the end of the first row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure how

to
terminate here
|This is the second text row | Still second | before
conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed








  #7  
Old December 20th, 2006, 12:13 AM posted to microsoft.public.word.tables
Suzanne S. Barnhill
external usenet poster
 
Posts: 31,786
Default Two rows per row?

1,500? You have 50 row pairs, each with four columns. I make that 200. Not
that I'd want to do it that many times, either.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Ed Sheehan" wrote in message
...
Yeah, I was hoping to avoid going thru those steps 1,500 times. Since one
can merely press Enter in a cell to create an embedded new row, I

thought
there might be a tag or something I could embed to create the same effect

in
conversion. But, I guess not. Also, if you do it manually, then convert
table to text, then text to table, you'll lose the groupings, so Word
doesn't preserve that info thru the conversion procedure either.

I may need to rethink the double row deal and maybe scrunch it together on
the same row.

Thanks for your help,

Ed


"Suzanne S. Barnhill" wrote in message
...
In other words, you basically have a table created with tabs, as

follows:

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

There's undoubtedly a way to do this programmatically, but I think I

would
be inclined to start by converting to a four-column table, separating at
tabs. If the line breaks cause an issue, convert them to paragraph

breaks
first. Then merge cells vertically to group each pair of entries, using

F4
to repeat the operation. Or create the groups visually using line

spacing
and application or omission of cell borders.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
What I an trying for is to flow two text rows into one table row. I

already
have 4 columns defined via embedded tabs. It's just that the two rows

are
related so I want them in their own table rows.

So if I have 100 text rows, I would end up with 50 table rows, each

with
two
rows of text inside, for all 4 columns.

Sorry if I'm explaining this badly.

Ed

"Suzanne S. Barnhill" wrote in message
...
I think what you're asking is whether you can create a two-column

table
out
of two-line text paragraphs, separating at the line break. I suspect

not.
Replace the line break (^l) with a paragraph break (^p) and then
convert
text to table, separating at paragraph breaks, but forcing a

two-column
table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
I have a bunch of rows with every other row terminated by a CR. The
previous
row is terminated by a manual line break. Can I convert text to

table
and
have the two rows occupy one table row, with the end of the first

row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure

how
to
terminate here
|This is the second text row | Still second | before
conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed









  #8  
Old December 20th, 2006, 03:10 PM posted to microsoft.public.word.tables
Ed Sheehan
external usenet poster
 
Posts: 14
Default Two rows per row?

Thanks Lene,

While I was parsing the rows, I discovered that some row "groupings" consist
of three rows. As I read your macro, do I interpret it correctly that it
uses a counter to mathematically arrive at an 'every other row' scheme? If
so, I wonder if it would be possible to group/merge the rows by looking for
a carriage return to establish a new table row.

Thanks very much for the macro. I'll give it a try.

Ed

"Lene Fredborg" wrote in message
...
I understood the explanation in the same way as explained by Suzanne in the
latest post. If this is correct, I think that the macro below will convert
your text to a table the way you want.

Copy the macro and paste it into your Visual Basic editor. Before
executing
it, you must select _all_ the text you want to include in the table.

The macro converts the text to a table with 4 columns (separated by your
tabs). Then it merges cells two and two in order to have your two related
lines inserted in the same table cell. You may need to change table
borders,
column widths, etc. afterwards.

Sub ConvertToTable()
Dim oTable As Table
Dim n As Long
Dim i As Long

Set oTable = Selection.ConvertToTable(Separator:=vbTab, numcolumns:=4)
With oTable
For n = 1 To .Rows.Count / 2
For i = 1 To 4
.Cell(n, i).Range.Select
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Cells.Merge
Next i
Next n
.Cell(1, 1).Select
End With
set otable = nothing
End Sub

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Suzanne S. Barnhill" wrote:

In other words, you basically have a table created with tabs, as follows:

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

There's undoubtedly a way to do this programmatically, but I think I
would
be inclined to start by converting to a four-column table, separating at
tabs. If the line breaks cause an issue, convert them to paragraph breaks
first. Then merge cells vertically to group each pair of entries, using
F4
to repeat the operation. Or create the groups visually using line spacing
and application or omission of cell borders.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
What I an trying for is to flow two text rows into one table row. I

already
have 4 columns defined via embedded tabs. It's just that the two rows
are
related so I want them in their own table rows.

So if I have 100 text rows, I would end up with 50 table rows, each
with

two
rows of text inside, for all 4 columns.

Sorry if I'm explaining this badly.

Ed

"Suzanne S. Barnhill" wrote in message
...
I think what you're asking is whether you can create a two-column
table

out
of two-line text paragraphs, separating at the line break. I suspect

not.
Replace the line break (^l) with a paragraph break (^p) and then
convert
text to table, separating at paragraph breaks, but forcing a
two-column
table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
I have a bunch of rows with every other row terminated by a CR. The
previous
row is terminated by a manual line break. Can I convert text to
table

and
have the two rows occupy one table row, with the end of the first
row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure
how

to
terminate here
|This is the second text row | Still second | before
conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed









  #9  
Old December 20th, 2006, 07:34 PM posted to microsoft.public.word.tables
Lene Fredborg
external usenet poster
 
Posts: 1,294
Default Two rows per row?

Yes, the macro in my first post merges cells from exactly 2 rows at a time
(in line with your first description). The macro converts the entire text in
one operation and all manual line breaks and paragraph mark are gone
afterwards.

Below you will find a revised (and much longer) version of the macro. In
order to make it possible to determine which lines had a paragraph mark in
the original text, the macro starts inserting the character “#” in front of
all paragraph marks. When merging cells, the macro finds out how many cells
to include by checking for the “#”. All inserted “#” are removed after
merging cells.

The macro should do what you want provided that the following is true:
– you have exactly 3 tabs in each line
– all lines that are to be kept together with the “paragraph mark line” in
one cell end with a manual line break (the macro works for any number of
lines, not only 2 or 3)
– the character “#” is _not_ found in the last “column” of your original
text. If it _is_ found, replace all occurrences of “#” in the macro by
another _unused_ character ($, @, £, …).

Please note that I have not spent time on making the macro code very elegant
(I assume that you only need the macro for one document). The macro uses the
Selection object which actually means that you can follow what happens if you
run the macro from the VBA window and use F8 to step through the code (press
F5 to finish the macro once you have seen what happens – and make the VBA
window so small that you can see what is going on in the document).

NOTE: Long code lines may be broken here (must be corrected in VBA). Before
running the macro, you must again select _all_ text that is to be included in
the table.


Sub ConvertToTable()

Dim oTable As Table
Dim n As Long
Dim i As Long
Dim nRowCount As Long
Dim nRowsToAdd As Long

'Insert # before all manual line breaks
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = "#^p"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With

Set oTable = Selection.ConvertToTable(Separator:=vbTab, numcolumns:=4)
With oTable
nRowCount = .Rows.Count
For n = 1 To nRowCount
If n nRowCount Then Exit For
nRowsToAdd = 0
For i = 4 To 1 Step -1
'Add rows until # is not found in last selected cell
.Cell(n, i).Range.Select
'Column 4: find out how many cells to merge
If i = 4 Then
'Add cells until # in last cell or until last row in table
Do Until InStr(1,
Selection.Rows.Last.Cells(4).Range.Text, "#", vbTextCompare) 0 Or _

..Columns.Last.Cells(.Rows.Count).Range.InRange(Se lection.Range) = True
On Error Resume Next 'may be used at end of table
Selection.MoveDown Unit:=wdLine, Count:=1,
Extend:=wdExtend
nRowsToAdd = nRowsToAdd + 1
Loop
Else
'Do the same in columns 1-3
Selection.MoveDown Unit:=wdLine, Count:=nRowsToAdd,
Extend:=wdExtend
End If
'Include relevant cells in selection
Selection.Cells.Merge
Next i
'Number of rows must be adjusted
nRowCount = .Rows.Count
Next n
End With

'Remove # again
oTable.Columns.Last.Select
With Selection.Find
.Text = "#"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With

oTable.Cell(1, 1).Select
Set oTable = Nothing
MsgBox "Finished."

End Sub

See this article if you need help on installing the macro:
http://www.gmayor.com/installing_macro.htm if you need help on this.

--
Regards
Lene Fredborg
DocTools – Denmark
www.thedoctools.com
Document automation – add-ins, macros and templates for Microsoft Word


"Ed Sheehan" wrote:

Thanks Lene,

While I was parsing the rows, I discovered that some row "groupings" consist
of three rows. As I read your macro, do I interpret it correctly that it
uses a counter to mathematically arrive at an 'every other row' scheme? If
so, I wonder if it would be possible to group/merge the rows by looking for
a carriage return to establish a new table row.

Thanks very much for the macro. I'll give it a try.

Ed

"Lene Fredborg" wrote in message
...
I understood the explanation in the same way as explained by Suzanne in the
latest post. If this is correct, I think that the macro below will convert
your text to a table the way you want.

Copy the macro and paste it into your Visual Basic editor. Before
executing
it, you must select _all_ the text you want to include in the table.

The macro converts the text to a table with 4 columns (separated by your
tabs). Then it merges cells two and two in order to have your two related
lines inserted in the same table cell. You may need to change table
borders,
column widths, etc. afterwards.

Sub ConvertToTable()
Dim oTable As Table
Dim n As Long
Dim i As Long

Set oTable = Selection.ConvertToTable(Separator:=vbTab, numcolumns:=4)
With oTable
For n = 1 To .Rows.Count / 2
For i = 1 To 4
.Cell(n, i).Range.Select
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Cells.Merge
Next i
Next n
.Cell(1, 1).Select
End With
set otable = nothing
End Sub

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Suzanne S. Barnhill" wrote:

In other words, you basically have a table created with tabs, as follows:

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

Field 1tabField 2tabField 3tabField 4line break
Field 1tabField 2tabField 3tabField 4paragraph break

There's undoubtedly a way to do this programmatically, but I think I
would
be inclined to start by converting to a four-column table, separating at
tabs. If the line breaks cause an issue, convert them to paragraph breaks
first. Then merge cells vertically to group each pair of entries, using
F4
to repeat the operation. Or create the groups visually using line spacing
and application or omission of cell borders.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
What I an trying for is to flow two text rows into one table row. I
already
have 4 columns defined via embedded tabs. It's just that the two rows
are
related so I want them in their own table rows.

So if I have 100 text rows, I would end up with 50 table rows, each
with
two
rows of text inside, for all 4 columns.

Sorry if I'm explaining this badly.

Ed

"Suzanne S. Barnhill" wrote in message
...
I think what you're asking is whether you can create a two-column
table
out
of two-line text paragraphs, separating at the line break. I suspect
not.
Replace the line break (^l) with a paragraph break (^p) and then
convert
text to table, separating at paragraph breaks, but forcing a
two-column
table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup
so
all may benefit.

"Ed Sheehan" wrote in message
...
I have a bunch of rows with every other row terminated by a CR. The
previous
row is terminated by a manual line break. Can I convert text to
table
and
have the two rows occupy one table row, with the end of the first
row
holding a soft return?

I can manipulate these characters into something else if needed.

|-----------------------------|---------------------|
|This is the first text row | Still the first row | - Not sure
how
to
terminate here
|This is the second text row | Still second | before
conversion.
|-----------------------------|---------------------|
|This would be table row 2 | and so on |
|Table row 2, text row 4 | and so on |
|-----------------------------|---------------------|

Thanks,

Ed










 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.