TOC Question

F

Fuzzhead

I’m trying to format my TOC as Follows:

1.0 text

2.0 text

2.1 text
2.2 text
2.3 text

3.0 text

3.1 text
3.2 text
3.3 text

and so on…


My macro gives me this:


1.0 text

2.0 text

2.1 text
2.2 text
2.3 text
3.0 text

3.1 text
3.2 text
3.3 text

and so on...

My question is how do I get a return between 2.3 and 3.0?

Here’s my Macro:

With ActiveDocument.Styles("TOC 1")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 1").ParagraphFormat
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceDouble
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevel1
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 1").NoSpaceBetweenParagraphsOfSameStyle = False

With ActiveDocument.Styles("TOC 2")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 2").ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.RightIndent = InchesToPoints(0.4)
.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 = InchesToPoints(-0.5)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 2").NoSpaceBetweenParagraphsOfSameStyle = False
ActiveDocument.Styles("TOC 2").ParagraphFormat.TabStops.ClearAll
ActiveDocument.Styles("TOC 2").ParagraphFormat.TabStops.Add Position:= _
InchesToPoints(0.5), Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
ActiveDocument.Styles("TOC 2").ParagraphFormat.TabStops.Add Position:= _
InchesToPoints(6.88), Alignment:=wdAlignTabRight, Leader:= _
wdTabLeaderSpaces

With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
LowerHeadingLevel:=2, IncludePageNumbers:=True, AddedStyles:="", _
UseHyperlinks:=False, HidePageNumbersInWeb:=True, UseOutlineLevels:= _
True
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With
 
J

Jean-Guy Marcil

Fuzzhead said:
I’m trying to format my TOC as Follows:

1.0 text

2.0 text

2.1 text
2.2 text
2.3 text

3.0 text

3.1 text
3.2 text
3.3 text

and so on…


My macro gives me this:


1.0 text

2.0 text

2.1 text
2.2 text
2.3 text
3.0 text

3.1 text
3.2 text
3.3 text

and so on...

My question is how do I get a return between 2.3 and 3.0?

If you observe this behaviour only between 2.3 and 3.0, make sure that the
paragraph 3.0 is indeed assigned the TOC level 1 style. If not, make sure
that its corresponding heading in the document is assigned the proper style.
If it is, then you have something interfering, like a hidden ¶ at the end of
the paragraph 2.3 in your document.

By the way, since you used the macro recorder, you might want to check out
this page:
http://word.mvps.org/faqs/macrosvba/ModifyRecordedMacro.htm
 
J

Jean-Guy Marcil

Fuzzhead said:
Thank you for the information. I found where my mistake was and corrected it.

Glad I could help... But for the sake of completeness, the mistake was... ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top