Attribute VB_Name = "NewMacros"
Sub PPOL_TOC()
Attribute PPOL_TOC.VB_Description = "Adds page numbers and Table of Contents\r\nto PPOL  Suitability Report\r\nBy Paraplanning Online Limited"
Attribute PPOL_TOC.VB_ProcData.VB_Invoke_Func = "Normal.NewMacros.PPOL_TOC"
'
' PPOL_TOC Macro
' Adds page numbers and Table of Contents
' "&chr(10)&"to PPOL  Suitability Report
' "&chr(10)&"By Paraplanning Online Limited
' Updated to handle covering letter
'
    Selection.Sections(1).Footers(1).PageNumbers.Add PageNumberAlignment:= _
        wdAlignPageNumberCenter, FirstPage:=False
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "{{TOC}}"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchByte = False
        .CorrectHangulEndings = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .MatchFuzzy = False
    End With
    Selection.Find.Execute
    Selection.HomeKey Unit:=wdLine
    Selection.InsertBreak Type:=wdPageBreak
    With ActiveDocument
        .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
            True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
            LowerHeadingLevel:=3, IncludePageNumbers:=True, AddedStyles:="", _
            UseHyperlinks:=True, HidePageNumbersInWeb:=True, UseOutlineLevels:= _
            True
        .TablesOfContents(1).TabLeader = wdTabLeaderDots
        .TablesOfContents.Format = wdIndexIndent
    End With
    Selection.WholeStory
    Selection.Fields.Update
    Selection.HomeKey Unit:=wdStory
End Sub
