Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Document Management / May 2008

Tip: Looking for answers? Try searching our database.

TOC fills only 1/2 page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LEU - 23 May 2008 21:14 GMT
When I create a TOC it only fills a little over half a page and then goes to
the next page and does the same thing. How do I get it to fill the whole
page?  I’m using Word 2003.
Lene Fredborg - 23 May 2008 21:57 GMT
I am not sure from your description, but the problem could be that one or
more of the TOC styles have been defined with “Page break before” turned on
(set in the Paragraph dialog box, Lines and Page Breaks tab). If this is the
case, modify the TOC style(s) in question.

Normally, TOC 1 is related to Heading 1, TOC 2 to Heading 2, etc.

For help on modifying a style, see:
http://www.shaunakelly.com/word/styles/ModifyAStyle.html

Signature

Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

> When I create a TOC it only fills a little over half a page and then goes to
> the next page and does the same thing. How do I get it to fill the whole
> page?  I’m using Word 2003.
LEU - 23 May 2008 23:00 GMT
Hi Lene,

I am using TOC 1 and TOC 2. I do not see any Lines and Page breaks tab. Any
other ideas?

> I am not sure from your description, but the problem could be that one or
> more of the TOC styles have been defined with “Page break before” turned on
[quoted text clipped - 9 lines]
> > the next page and does the same thing. How do I get it to fill the whole
> > page?  I’m using Word 2003.
Lene Fredborg - 23 May 2008 23:32 GMT
The Line and Page Breaks tab is one of the tabs in the dialog box named
Paragraph.

Signature

Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

> Hi Lene,
>
[quoted text clipped - 14 lines]
> > > the next page and does the same thing. How do I get it to fill the whole
> > > page?  I’m using Word 2003.
LEU - 23 May 2008 23:41 GMT
Lene,

Nothing is checked in the Line and Page Breaks. Also, if I create a TOC
using the toolbar it works (uses the full page). If I record it as a macro
and run it, it only uses half of the page.

> The Line and Page Breaks tab is one of the tabs in the dialog box named
> Paragraph.
[quoted text clipped - 17 lines]
> > > > the next page and does the same thing. How do I get it to fill the whole
> > > > page?  I’m using Word 2003.
Lene Fredborg - 24 May 2008 00:18 GMT
Could you post the macro? Maybe it will help finding the problem.
(I may not look at your macro until tomorrow - it is well after midnight in
Denmark now).

Signature

Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

> Lene,
>
[quoted text clipped - 23 lines]
> > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > page?  I’m using Word 2003.
LEU - 24 May 2008 01:25 GMT
Lene,

Here it is.

Sub CreateTOC()

   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.5)
       .SpaceBefore = 12
       .SpaceBeforeAuto = False
       .SpaceAfter = 0
       .SpaceAfterAuto = False
       .LineSpacingRule = wdLineSpaceSingle
       .Alignment = wdAlignParagraphLeft
       .WidowControl = False
       .KeepWithNext = False
       .KeepTogether = False
       .PageBreakBefore = False
       .NoLineNumber = False
       .Hyphenation = False
       .FirstLineIndent = InchesToPoints(0)
       .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 = True
       .BaseStyle = "Normal"
       .NextParagraphStyle = "Normal"
   End With
   With ActiveDocument.Styles("TOC 2").ParagraphFormat
       .LeftIndent = InchesToPoints(0.5)
       .RightIndent = InchesToPoints(0.5)
       .SpaceBefore = 12
       .SpaceBeforeAuto = False
       .SpaceAfter = 0
       .SpaceAfterAuto = False
       .LineSpacingRule = wdLineSpaceSingle
       .Alignment = wdAlignParagraphLeft
       .WidowControl = False
       .KeepWithNext = False
       .KeepTogether = False
       .PageBreakBefore = False
       .NoLineNumber = False
       .Hyphenation = False
       .FirstLineIndent = InchesToPoints(-0.5)
       .OutlineLevel = wdOutlineLevelBodyText
       .CharacterUnitLeftIndent = 0
       .CharacterUnitRightIndent = 0
       .CharacterUnitFirstLineIndent = 0
       .LineUnitBefore = 0
       .LineUnitAfter = 0
   End With
   ActiveDocument.Styles("TOC 2").NoSpaceBetweenParagraphsOfSameStyle = True
   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.5)
       .SpaceBefore = 12
       .SpaceBeforeAuto = False
       .SpaceAfter = 0
       .SpaceAfterAuto = False
       .LineSpacingRule = wdLineSpaceSingle
       .Alignment = wdAlignParagraphLeft
       .WidowControl = False
       .KeepWithNext = False
       .KeepTogether = False
       .PageBreakBefore = False
       .NoLineNumber = False
       .Hyphenation = False
       .FirstLineIndent = InchesToPoints(0)
       .OutlineLevel = wdOutlineLevelBodyText
       .CharacterUnitLeftIndent = 0
       .CharacterUnitRightIndent = 0
       .CharacterUnitFirstLineIndent = 0
       .LineUnitBefore = 0
       .LineUnitAfter = 0
   End With
   ActiveDocument.Styles("TOC 1").NoSpaceBetweenParagraphsOfSameStyle = False
   With ActiveDocument
       .TablesOfContents.Add Range:=Selection.Range,
RightAlignPageNumbers:= _
           True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
           LowerHeadingLevel:=2, UseFields:=True, TableID:="C", _
           IncludePageNumbers:=True, AddedStyles:="", UseHyperlinks:=False, _
           HidePageNumbersInWeb:=True, UseOutlineLevels:=True
       .TablesOfContents(1).TabLeader = wdTabLeaderDots
       .TablesOfContents.Format = wdIndexIndent
   End With

End Sub

> Could you post the macro? Maybe it will help finding the problem.
> (I may not look at your macro until tomorrow - it is well after midnight in
[quoted text clipped - 27 lines]
> > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > page?  I’m using Word 2003.
Lene Fredborg - 24 May 2008 11:55 GMT
I have looked at your code and tested it and I cannot see anything that
should cause the problems you experience.

Does the problem occur in a single document only?

Does it make any difference if you replace the code between “With
ActiveDocument” and “End With” by the following code?

       Dim oField As Field
       Set oField = .Fields.Add(Range:=Selection.Range, Type:=wdFieldEmpty)
       With oField
           .Code.Text = "TOC \o " & Chr(34) & "1-2" & Chr(34) & " \h \z "
           .Update
       End With
       Set oField = Nothing

The code above adds a TOC field with the field code:
TOC \o “1-2” \h \z   (delete \h from the code above if you do not want the
TOC entries to work as hyperlinks)
whereas the field inserted by your code has other switches:
TOC \o “1-2” \f \z \u

The Word help tells about the \u switch: Builds a table of contents by using
the applied paragraph outline level.

Do you have TC fields in the document? (the \f switch)

Actually, I cannot tell whether it would make any difference replacing the
code but it may be worth a try.

If it does not help, you could e-mail the problem document to me (you can
extract an e-mail address from my profile). I will then have a look in order
to see whether I can find out what happens.

Signature

Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

> Lene,
>
[quoted text clipped - 133 lines]
> > > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > > page?  I’m using Word 2003.
LEU - 24 May 2008 16:14 GMT
Lene,

I tried your macro but get the following error at .Fields.Add

Compile error: Invalid or unqualified reference

> I have looked at your code and tested it and I cannot see anything that
> should cause the problems you experience.
[quoted text clipped - 167 lines]
> > > > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > > > page?  I’m using Word 2003.
LEU - 24 May 2008 16:20 GMT
I forgot to say that I tried it on other documents and it did the same thing
on them. The TOC fills only half a page.

> I have looked at your code and tested it and I cannot see anything that
> should cause the problems you experience.
[quoted text clipped - 167 lines]
> > > > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > > > page?  I’m using Word 2003.
Lene Fredborg - 24 May 2008 16:45 GMT
When inserting the new code lines, you must keep the lines:
With ActiveDocument
  (insert the code here)
End With

Maybe you removed the With/End With lines?

Signature

Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

> I forgot to say that I tried it on other documents and it did the same thing
> on them. The TOC fills only half a page.
[quoted text clipped - 170 lines]
> > > > > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > > > > page?  I’m using Word 2003.
LEU - 24 May 2008 18:46 GMT
Lene,

The problem is in the \h . If I include it the macro the TOC fills the whole
page but the formatting is wrong. If I take out \h the TOC fills half the
page but the TOC format is correct.



> When inserting the new code lines, you must keep the lines:
> With ActiveDocument
[quoted text clipped - 177 lines]
> > > > > > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > > > > > page?  I’m using Word 2003.
Lene Fredborg - 24 May 2008 19:12 GMT
I am definitely not sure what happens. Have you checked the style definition
of the Hyperlink style (applied as a character style on top of the TOC styles
when the \h switch is included)? By default, Hyperlink will be defined to add
blue color and underline - however, it may be modified to whatever a
character style can be.

Signature

Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

> Lene,
>
[quoted text clipped - 185 lines]
> > > > > > > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > > > > > > page?  I’m using Word 2003.
LEU - 24 May 2008 19:06 GMT
Lene,

I figured out the problem. In the following part of the macro I deleted the
following line and it worked fine. The TOC filled the whole page.

HidePageNumbersInWeb:=True, UseOutlineLevels:=True

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

> When inserting the new code lines, you must keep the lines:
> With ActiveDocument
[quoted text clipped - 177 lines]
> > > > > > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > > > > > page?  I’m using Word 2003.
Lene Fredborg - 24 May 2008 19:30 GMT
I am glad the problem is solved.

Signature

Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

> Lene,
>
[quoted text clipped - 194 lines]
> > > > > > > > > > > the next page and does the same thing. How do I get it to fill the whole
> > > > > > > > > > > page?  I’m using Word 2003.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.