From: Associates on
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



From: Doug Robbins - Word MVP on
Why use code to define the Styles? Use the Modify button in the Table of
Contents dialog and then select the style that you want to modify and click
on the Modify button in the Style dialog.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Associates" <Associates(a)discussions.microsoft.com> wrote in message
news:46A29DA9-6285-410C-A8EA-625DD56F9CDF(a)microsoft.com...
> 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
>
>
>