View Single Post
 
Old 09-02-2021, 03:52 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I think it would be relatively easy to create a macro to identify duplicated sentences if they are exact matches. If every sentence was loaded to a dictionary, you would get an error if the key already exists. It would only take a single character to differ to render this method invalid though.

Is this what you are looking for? It should highlight any sentence that has already been used in the document (ignoring case, spaces, tabs, periods)
Code:
Sub RepeatOffenders()
  'Requires a reference to Microsoft Scripting Runtime
  'Highlights sentence repeats in document
  Dim aSent As Range, sText As String, aDict As Scripting.Dictionary
  
  Set aDict = New Scripting.Dictionary
  For Each aSent In ActiveDocument.Range.Sentences
    sText = Replace(LCase(aSent.Text), vbCr, "")
    sText = Replace(sText, " ", "")
    sText = Replace(sText, ",", "")
    sText = Replace(sText, ".", "")
    sText = Replace(sText, vbTab, "")
    'Debug.Print sText
    On Error GoTo Plagiariser2000
    aDict.Add sText, sText
  Next aSent
  Exit Sub
Plagiariser2000:
  aSent.HighlightColorIndex = wdBrightGreen
  Resume Next
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia

Last edited by Guessed; 09-02-2021 at 08:50 PM.
Reply With Quote