Converting text to table

C

Carlos Chalhoub

Hi listmates,

I have hundreds of documents containing different styles. We've decided to
change some bulleted paragraphs into 2-column tables with set widths. Most
of these have a "List Bullet" style. I have created a macro that does the
conversion when the selection contains only one type of bullet (usually
"List Bullet").

Sub ConvertBulletsToTables()
'
' ConvertBulletsToTables Macro
' Macro created 6/15/2004 by CHALHOUC
'
mySelection = Selection.Paragraphs.Count
Selection.ConvertToTable Separator:=wdSeparateByParagraphs, _
NumColumns:=1, NumRows:=mySelection
With Selection
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
.InsertColumnsRight
.Collapse Direction:=wdCollapseStart
.Move Unit:=wdColumn, Count:=-1
.SelectColumn
.Columns.PreferredWidthType = wdPreferredWidthPoints
.Columns.PreferredWidth = InchesToPoints(2)
.Move Unit:=wdColumn, Count:=1
.SelectColumn
.Tables(1).PreferredWidthType = wdPreferredWidthPoints
.Tables(1).PreferredWidth = InchesToPoints(6.5)
.Columns.PreferredWidthType = wdPreferredWidthPoints
.Columns.PreferredWidth = InchesToPoints(4.5)
.Tables(1).Select
.Style = ActiveDocument.Styles("Normal")
End With

End Sub

Now, I need to extend the application of this macro to selections containing
"List Bullet", "List Bullet 2" and "Note" styles.
The "List Bullet" paragraphs always go in the 1st column. "List Bullet 2"
and "Note" styles are nested and always go in the 2nd column. Moreover,
"List Bullet 2" and "Note" styles always follow a "List Bullet" paragraph
(they contain descriptions), i.e. they should be in the cell immediately to
the right of the "List Bullet" style.

I need to change the macro so that it looks at the style. If it is a "List
Bullet", it puts the paragraph in the 1st column (starting with cell 1). If
the paragraph following it is "List Bullet" too, it goes again in the 1st
column in the cell below. If the style is "List Bullet 2" or "Note", it will
go in the 2nd column at the same level as the "List Bullet" paragraph
preceding it. The macro has to go through the whole selection until all
paragraphs have been placed in the proper cell. There may be some special
cases, but I'll deal with those on manually. Can this be done? Thanks for
any help.
 
W

Word Heretic

G'day "Carlos Chalhoub" <[email protected]>,

It sure can be done. You look at the ListFormat.ListLevel for the
para's range.

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Carlos Chalhoub reckoned:
 

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