L
Lee
I used VBA to set up List Number 0- List Number 3 outline
numbering styles. 1 and 3 work perfectly. However, List
Number 2 is not exactly indenting correctly. The hanging
text indents correctly. But, the number and the text are
right next to each other until the list reaches 10 or
greater. This happens no matter how much of an indent I
use.
Code follows. Any suggestions would be helpful.
Thank you!
Lee
Sub SetupListNumbering()
'
'
Dim oLstTemplate As ListTemplate, TemplateFound As Boolean
'-------------------------------------------------
'-------------------------------------------------
'Find or Create List 0
bFound = False
For Each MyStyle In ActiveDocument.Styles
If MyStyle.NameLocal = "List Number 0" Then
bFound = True
End If
Next MyStyle
If Not (bFound) Then
ActiveDocument.Styles.Add Name:="List Number 0",
Type:=wdStyleTypeParagraph
End If
'-------------------------------------------------
'-------------------------------------------------
'Then SET UP THE STYLES
With ActiveDocument.Styles("List Number 0")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "List Number"
With .ParagraphFormat
.SpaceAfter = 0
.SpaceBefore = 0
.LeftIndent = 0
.RightIndent = 0
.HangingPunctuation = True
.KeepWithNext = True
.LineSpacingRule = wdLineSpaceSingle
End With
.Font.Size = 1
End With
'-------------------------------------------------
With ActiveDocument.Styles("List Number")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "List Number"
With .ParagraphFormat
.SpaceAfter = 6
.SpaceBefore = 0
.LeftIndent = 0
.RightIndent = 0
.HangingPunctuation = True
.KeepWithNext = True
.LineSpacingRule = wdLineSpaceSingle
End With
End With
'-------------------------------------------------
With ActiveDocument.Styles("List Number 2")
.AutomaticallyUpdate = False
.BaseStyle = "List Number"
.NextParagraphStyle = "List Number 2"
With .ParagraphFormat
.SpaceAfter = 6
.SpaceBefore = 0
.LeftIndent = 0
.RightIndent = 0
.HangingPunctuation = True
.KeepWithNext = True
.LineSpacingRule = wdLineSpaceSingle
End With
End With
'-------------------------------------------------
With ActiveDocument.Styles("List Number 3")
.AutomaticallyUpdate = False
.BaseStyle = "List Number 2"
.NextParagraphStyle = "List Number 3"
With .ParagraphFormat
.SpaceAfter = 6
.SpaceBefore = 0
.LeftIndent = 0
.RightIndent = 0
.HangingPunctuation = True
.KeepWithNext = True
.LineSpacingRule = wdLineSpaceSingle
End With
End With
'-------------------------------------------------
With ActiveDocument.Styles("List Number 4")
.AutomaticallyUpdate = False
.BaseStyle = "List Number 3"
.ParagraphFormat.SpaceAfter = 6
.ParagraphFormat.HangingPunctuation = True
End With
'----------------------------------------------------------
------
'----------------------------------------------------------
------
'THEN FIND OR CREATE THE LIST TEMPLATE
For Each oLstTemplate In ActiveDocument.ListTemplates
If oLstTemplate.Name = "ListNumberTemplate" Then
TemplateFound = True
Exit For
End If
Next oLstTemplate
'----------------------------------------------------------
------
If TemplateFound Then
Set oLstTemplate = ActiveDocument.ListTemplates
("ListNumberTemplate")
Else
Set oLstTemplate = ActiveDocument.ListTemplates.Add
(OutlineNumbered:=True)
oLstTemplate.Name = "ListNumberTemplate"
End If
'----------------------------------------------------------
------
'----------------------------------------------------------
------
'THEN DEFINE THE LIST TEMPLATE
With oLstTemplate.ListLevels(1)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleLegal
.NumberPosition = InchesToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.35)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number 0"
End With
'-------------------------------------------------
With oLstTemplate.ListLevels(2)
.NumberFormat = "%2."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(0.4)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.65)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number"
End With
'-------------------------------------------------
With oLstTemplate.ListLevels(3)
.NumberFormat = "%3."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(0.85)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(1.15)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number 2"
End With
'-------------------------------------------------
With oLstTemplate.ListLevels(4)
.NumberFormat = "%4."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(1.45)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(1.7)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number 3"
End With
'-------------------------------------------------
With oLstTemplate.ListLevels(5)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleNone
.NumberPosition = InchesToPoints(1.4)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(2.4)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number 4"
End With
End Sub
numbering styles. 1 and 3 work perfectly. However, List
Number 2 is not exactly indenting correctly. The hanging
text indents correctly. But, the number and the text are
right next to each other until the list reaches 10 or
greater. This happens no matter how much of an indent I
use.
Code follows. Any suggestions would be helpful.
Thank you!
Lee
Sub SetupListNumbering()
'
'
Dim oLstTemplate As ListTemplate, TemplateFound As Boolean
'-------------------------------------------------
'-------------------------------------------------
'Find or Create List 0
bFound = False
For Each MyStyle In ActiveDocument.Styles
If MyStyle.NameLocal = "List Number 0" Then
bFound = True
End If
Next MyStyle
If Not (bFound) Then
ActiveDocument.Styles.Add Name:="List Number 0",
Type:=wdStyleTypeParagraph
End If
'-------------------------------------------------
'-------------------------------------------------
'Then SET UP THE STYLES
With ActiveDocument.Styles("List Number 0")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "List Number"
With .ParagraphFormat
.SpaceAfter = 0
.SpaceBefore = 0
.LeftIndent = 0
.RightIndent = 0
.HangingPunctuation = True
.KeepWithNext = True
.LineSpacingRule = wdLineSpaceSingle
End With
.Font.Size = 1
End With
'-------------------------------------------------
With ActiveDocument.Styles("List Number")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "List Number"
With .ParagraphFormat
.SpaceAfter = 6
.SpaceBefore = 0
.LeftIndent = 0
.RightIndent = 0
.HangingPunctuation = True
.KeepWithNext = True
.LineSpacingRule = wdLineSpaceSingle
End With
End With
'-------------------------------------------------
With ActiveDocument.Styles("List Number 2")
.AutomaticallyUpdate = False
.BaseStyle = "List Number"
.NextParagraphStyle = "List Number 2"
With .ParagraphFormat
.SpaceAfter = 6
.SpaceBefore = 0
.LeftIndent = 0
.RightIndent = 0
.HangingPunctuation = True
.KeepWithNext = True
.LineSpacingRule = wdLineSpaceSingle
End With
End With
'-------------------------------------------------
With ActiveDocument.Styles("List Number 3")
.AutomaticallyUpdate = False
.BaseStyle = "List Number 2"
.NextParagraphStyle = "List Number 3"
With .ParagraphFormat
.SpaceAfter = 6
.SpaceBefore = 0
.LeftIndent = 0
.RightIndent = 0
.HangingPunctuation = True
.KeepWithNext = True
.LineSpacingRule = wdLineSpaceSingle
End With
End With
'-------------------------------------------------
With ActiveDocument.Styles("List Number 4")
.AutomaticallyUpdate = False
.BaseStyle = "List Number 3"
.ParagraphFormat.SpaceAfter = 6
.ParagraphFormat.HangingPunctuation = True
End With
'----------------------------------------------------------
------
'----------------------------------------------------------
------
'THEN FIND OR CREATE THE LIST TEMPLATE
For Each oLstTemplate In ActiveDocument.ListTemplates
If oLstTemplate.Name = "ListNumberTemplate" Then
TemplateFound = True
Exit For
End If
Next oLstTemplate
'----------------------------------------------------------
------
If TemplateFound Then
Set oLstTemplate = ActiveDocument.ListTemplates
("ListNumberTemplate")
Else
Set oLstTemplate = ActiveDocument.ListTemplates.Add
(OutlineNumbered:=True)
oLstTemplate.Name = "ListNumberTemplate"
End If
'----------------------------------------------------------
------
'----------------------------------------------------------
------
'THEN DEFINE THE LIST TEMPLATE
With oLstTemplate.ListLevels(1)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleLegal
.NumberPosition = InchesToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.35)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number 0"
End With
'-------------------------------------------------
With oLstTemplate.ListLevels(2)
.NumberFormat = "%2."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(0.4)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.65)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number"
End With
'-------------------------------------------------
With oLstTemplate.ListLevels(3)
.NumberFormat = "%3."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(0.85)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(1.15)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number 2"
End With
'-------------------------------------------------
With oLstTemplate.ListLevels(4)
.NumberFormat = "%4."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(1.45)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(1.7)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number 3"
End With
'-------------------------------------------------
With oLstTemplate.ListLevels(5)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleNone
.NumberPosition = InchesToPoints(1.4)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(2.4)
.TabPosition = wdUndefined
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "List Number 4"
End With
End Sub