Sub CopyToListAlphabetic() ' Paul Beverley - Version 17.04.24 ' Copies selected text into an alphabetic list file ' keyWord = "queries" keyWord = "list" keyWord = "sheet" followHeading = "Word list" wordsToAvoid = "switch" ' wordsToAvoid = "FRedit,switch" ' copyWholePara = True copyWholePara = False includeFormatting = False ' includeFormatting = True goBackToSource = True Dim sourceText As Range, tgt As Range Set thisDoc = ActiveDocument wds = Split("," & LCase(wordsToAvoid), ",") If Selection.Start = Selection.End Then If Selection = vbCr Then Selection.MoveLeft , 1 If copyWholePara = True Then Selection.Expand wdParagraph Else Set rng = Selection.Range.Duplicate rng.Expand wdWord rng.MoveEnd wdWord, 1 chkWd = rng.Words.Last If chkWd = "-" Then rng.MoveEnd wdWord, 2 chkWd = rng.Words.Last If chkWd = "-" Then rng.MoveEnd wdWord, 1 Else rng.MoveEnd wdWord, -1 End If Else rng.MoveEnd wdWord, -1 End If DoEvents Do While InStr(ChrW(8217) & "' ", Right(rng.Text, 1)) > 0 rng.MoveEnd , -1 DoEvents Loop End If rng.Select Else Set rng = Selection.Range.Duplicate rng.Collapse wdCollapseEnd rng.MoveEnd , -1 rng.Expand wdWord Do While InStr(ChrW(8217) & "' ", Right(rng.Text, 1)) > 0 rng.MoveEnd , -1 DoEvents Loop Selection.Collapse wdCollapseStart Selection.Expand wdWord Selection.Collapse wdCollapseStart rng.Start = Selection.Start rng.Select End If With ActiveWindow.View.RevisionsFilter mState = .Markup .Markup = wdRevisionsMarkupSimple vState = .View .View = wdRevisionsViewFinal Set sourceText = Selection.Range.Duplicate myText = sourceText.Text numTracks = Selection.Range.Revisions.Count sourceText.Copy Selection.Collapse wdCollapseEnd .Markup = mState .View = vState End With gottaList = False For Each myDoc In Application.Documents thisName = myDoc.Name nm = LCase(thisName) gottaList = False If InStr(nm, LCase(keyWord)) > 0 Then gottaList = True For i = 1 To UBound(wds) If InStr(nm, wds(i)) > 0 Then gottaList = False Next i If gottaList = True Then Exit For Next myDoc If gottaList = False Then Beep MsgBox "Can't find a list." Exit Sub End If ' Decide where to put the item Set rng = myDoc.Content With rng.Find .ClearFormatting .Replacement.ClearFormatting .Text = followHeading .Wrap = wdFindStop .Forward = True .Replacement.Text = "" .MatchCase = True .MatchWildcards = False .Execute DoEvents End With rng.Expand wdParagraph listStart = rng.End If rng.Find.Found = False Then Beep MsgBox "Can't find heading: """ & followHeading & """" rng.Start = 0 rng.End = 0 listStart = 0 Selection.HomeKey Unit:=wdStory End If rng.Collapse wdCollapseStart ' Check if it's already in the list With rng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "^p" & myText & "^p" .Wrap = wdFindStop .Execute DoEvents End With If rng.Find.Found = True Then Beep If goBackToSource = False Then myDoc.Activate Exit Sub End If rng.Start = listStart rng.End = myDoc.Content.End If LCase(rng) <> UCase(rng) Then For i = 1 To rng.Paragraphs.Count myNextItem = Replace(rng.Paragraphs(i).Range.Text, vbCr, "") If LCase(myNextItem) > LCase(myText) Or _ LCase(myNextItem) = UCase(myNextItem) Then Set rng = rng.Paragraphs(i).Range.Duplicate Exit For End If Next i End If rng.Collapse wdCollapseStart ' Paste it in If includeFormatting = True Then rng.FormattedText = sourceText.FormattedText If InStr(myText, vbCr) = 0 Then rng.InsertAfter vbCr End If Else rng.InsertAfter myText If InStr(myText, vbCr) = 0 Then rng.InsertAfter vbCr End If rng.Revisions.AcceptAll If goBackToSource = False Then myDoc.Activate End Sub