L
LEU
I am trying to create a 3 level Table of Contend that looks like the following:
1.0 PURPOSE
1.1 Second Order Heading
1.2 Second Order Heading
1.3 Second Order Heading
1.3.1 Third Order Heading
1.3.2 Third Order Heading
1.4 Second Order Heading
2.0 PURPOSE
The following macro gives me this:
1.0 PURPOSE
1.1 Second Order Heading
1.2 Second Order Heading
1.3 Second Order Heading
1.3.1 Third Order Heading
1.3.2 Third Order Heading
1.4 Second Order Heading
2.0 PURPOSE
Here is my macro. How can I fix this?
With ActiveDocument.Styles("TOC 1")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "TOC 1"
End With
With ActiveDocument.Styles("TOC 2")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "TOC 2"
End With
With ActiveDocument.Styles("TOC 2").ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.RightIndent = InchesToPoints(0.5)
.SpaceBefore = 6
.SpaceBeforeAuto = False
.SpaceAfter = 6
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = False
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = False
.FirstLineIndent = InchesToPoints(-0.5)
.OutlineLevel = wdOutlineLevel2
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 2").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("TOC 3")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "TOC 3"
End With
With ActiveDocument.Styles("TOC 3").ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.RightIndent = InchesToPoints(0.5)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = False
.FirstLineIndent = InchesToPoints(-0.5)
.OutlineLevel = wdOutlineLevel3
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 3").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range,
RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
LowerHeadingLevel:=3, IncludePageNumbers:=True, AddedStyles:="", _
UseHyperlinks:=False, HidePageNumbersInWeb:=True,
UseOutlineLevels:= _
True, UseFields:=True
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With
1.0 PURPOSE
1.1 Second Order Heading
1.2 Second Order Heading
1.3 Second Order Heading
1.3.1 Third Order Heading
1.3.2 Third Order Heading
1.4 Second Order Heading
2.0 PURPOSE
The following macro gives me this:
1.0 PURPOSE
1.1 Second Order Heading
1.2 Second Order Heading
1.3 Second Order Heading
1.3.1 Third Order Heading
1.3.2 Third Order Heading
1.4 Second Order Heading
2.0 PURPOSE
Here is my macro. How can I fix this?
With ActiveDocument.Styles("TOC 1")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "TOC 1"
End With
With ActiveDocument.Styles("TOC 2")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "TOC 2"
End With
With ActiveDocument.Styles("TOC 2").ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.RightIndent = InchesToPoints(0.5)
.SpaceBefore = 6
.SpaceBeforeAuto = False
.SpaceAfter = 6
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = False
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = False
.FirstLineIndent = InchesToPoints(-0.5)
.OutlineLevel = wdOutlineLevel2
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 2").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("TOC 3")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "TOC 3"
End With
With ActiveDocument.Styles("TOC 3").ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.RightIndent = InchesToPoints(0.5)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = False
.FirstLineIndent = InchesToPoints(-0.5)
.OutlineLevel = wdOutlineLevel3
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 3").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range,
RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
LowerHeadingLevel:=3, IncludePageNumbers:=True, AddedStyles:="", _
UseHyperlinks:=False, HidePageNumbersInWeb:=True,
UseOutlineLevels:= _
True, UseFields:=True
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With