Sub ContentsListerByTag() ' Paul Beverley - Version 17.09.18 ' Creates a contents list from tags, , , etc. bringMainToFront = True removeTags = True myText = "B" Dim fnd(5) As String Dim rpl(5) As String ' two levels fnd(2) = ",,," rpl(2) = "^p^p^t,^p,,^t" ' three levels fnd(3) = ",,,," rpl(3) = "^p^p^t,^p,,^t,^t^t" ' four levels fnd(4) = ",,,,," rpl(4) = "^p^p^t,^p,,^t,^t^t,^t^t^t" ' five levels fnd(5) = ",,,,,," rpl(5) = "^p^p^t,^p,,^t,^t^t,^t^t^t,^t^t^t^t" Do myResponse = InputBox("Level? (B-E):", "Content Lister", myText) myLevel = Asc(UCase(myResponse)) - 64 Loop Until myLevel > 1 And myLevel < 6 myColour = wdTurquoise oldColour = Options.DefaultHighlightColorIndex Options.DefaultHighlightColorIndex = myColour Set thisDoc = ActiveDocument Set rng = ActiveDocument.Content Documents.Add Selection.Text = rng.Text Selection.EndKey unit:=wdStory myF = Split(fnd(myLevel), ",") myR = Split(rpl(myLevel), ",") For i = 0 To UBound(myF) myFind = Replace(myF(i), "<", "\<") myFind = Replace(myFind, ">", "\>") If Right(myR(i), 1) = "#" Then myCR = "^t" myR(i) = Replace(myR(i), "#", "") Else myCR = "^p" End If Set rng = ActiveDocument.Content With rng.Find .ClearFormatting .Replacement.ClearFormatting .Text = myFind & "(*)^13" .Wrap = wdFindContinue .Replacement.Text = myR(i) & "\1" & myCR .Replacement.Highlight = True .MatchWildcards = True .Execute Replace:=wdReplaceAll End With DoEvents StatusBar = " " & myR(i) Next i StatusBar = " Editing the list. Please wait..." With rng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "*" .Highlight = False .Replacement.Text = "" .MatchWildcards = True .Execute Replace:=wdReplaceAll End With If removeTags = True Then With rng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "\<*\>" .Wrap = wdFindContinue .Replacement.Text = "" .MatchWildcards = True .Execute Replace:=wdReplaceAll End With End If ' Pull chapter titles to chapter numbers With rng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "^t^p" .Replacement.Text = "^t" .MatchWildcards = False .Execute Replace:=wdReplaceAll End With Set rng = ActiveDocument.Content rng.HighlightColorIndex = wdNoHighlight Selection.HomeKey unit:=wdStory Options.DefaultHighlightColorIndex = oldColour If bringMainToFront = True Then thisDoc.Activate Beep End Sub