A
Associates
Hi,
I have a template that generates a report document. It has two TOCs with one
for body of the report and the other one for Appendixes.
I could manage to set up the hanging indentation to the first TOC in VB code
but not sure how to set the hanging indentation to the second TOC for
Appendixes.
In the report, the TOC is set as below
{ TOC \o "1-3" \h \z \u }
{ TOC \o "4-4" \n "4-4" \h \z }
Then, in the VB code, I have the following that applies to the first TOC
Sub setHangingIndent()
With ActiveDocument.Styles("TOC 1")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 1").ParagraphFormat
.LeftIndent = CentimetersToPoints(2)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 5
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(-2)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 1").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("TOC 2")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 2").ParagraphFormat
.LeftIndent = CentimetersToPoints(1.52)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(-1.1)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 2").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("TOC 3")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 3").ParagraphFormat
.LeftIndent = CentimetersToPoints(1.95)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(-1.1)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 3").NoSpaceBetweenParagraphsOfSameStyle = False
I wonder if anyone might be able to share me some knowledge of how to set
the hanging indent to the second TOC.
Any helps would be greatly appreciated.
Thank you in advance
I have a template that generates a report document. It has two TOCs with one
for body of the report and the other one for Appendixes.
I could manage to set up the hanging indentation to the first TOC in VB code
but not sure how to set the hanging indentation to the second TOC for
Appendixes.
In the report, the TOC is set as below
{ TOC \o "1-3" \h \z \u }
{ TOC \o "4-4" \n "4-4" \h \z }
Then, in the VB code, I have the following that applies to the first TOC
Sub setHangingIndent()
With ActiveDocument.Styles("TOC 1")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 1").ParagraphFormat
.LeftIndent = CentimetersToPoints(2)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 5
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(-2)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 1").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("TOC 2")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 2").ParagraphFormat
.LeftIndent = CentimetersToPoints(1.52)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(-1.1)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 2").NoSpaceBetweenParagraphsOfSameStyle = False
With ActiveDocument.Styles("TOC 3")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 3").ParagraphFormat
.LeftIndent = CentimetersToPoints(1.95)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(-1.1)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 3").NoSpaceBetweenParagraphsOfSameStyle = False
I wonder if anyone might be able to share me some knowledge of how to set
the hanging indent to the second TOC.
Any helps would be greatly appreciated.
Thank you in advance