Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Page Numbers come first in TOC (Word 2003)

    Dear All,

    Is it possible to create a TOC that has page numbers in front of the text? I cannot find such option within Word and I am just wondering if anybody has done it using VBA?

    Regards
    Rid

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Page Numbers come first in TOC (Word 2003)

    There is no built-in feature to do that, but you could insert a standard TOC and convert it:

    Sub InsertTOCWithLeadingPageNumbers()
    Dim rng As Range
    Dim tbl As Table
    Set rng = ActiveDocument.TablesOfContents.Add _
    (Range:=Selection.Range, _
    RightAlignPageNumbers:=True, _
    UseHeadingStyles:=True, _
    UpperHeadingLevel:=1, _
    LowerHeadingLevel:=3, _
    IncludePageNumbers:=True, _
    AddedStyles:="", _
    UseHyperlinks:=True, _
    UseOutlineLevels:=True).Range
    rng.Fields.Unlink
    Set tbl = rng.ConvertToTable _
    (Separator:=wdSeparateByTabs, _
    NumColumns:=2)
    tbl.Columns(2).Select
    Selection.Cut
    Selection.Paste
    tbl.ConvertToText Separator:=wdSeparateByTabs
    End Sub

  3. #3
    Star Lounger
    Join Date
    Feb 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Page Numbers come first in TOC (Word 2003)

    Thanks Hans,

    You are a life-saver.

    I was short of manually typing out the TOC.

    Regards
    Rid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •