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.
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.