Is there a function to find repeated phrases and sentences in a Word Document

I have a long Word Document and want a programme or function which will detect repeated phrases and sentences within the document.
|
Answer
Answer

You can use the Find utility to Find a particular phrase.  However, unless you define what it is for which you want to find possible repetitions, Word has no idea what you might want it is that you might want to do.  All it can do by itself is highlight consecutive instances of the same one word.

-- Hope this helps.

Doug Robbins - Word MVP,
dkr[atsymbol]mvps[dot]org
Posted via the Community Bridge

"janmet" wrote in message news:Email removed for privacy...

I have a long Word Document and want a programme or function which will detect repeated phrases and sentences within the document.

 

 


Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org


Well the Word object model knows the concept sentences. So in theory you could let it check all sentences in a 2 loop fashion. Something along the following lines:

========================

Sub Test()
    Dim i, j, nrOfSentences As Integer
    Dim s As String
   
    nrOfSentences = ActiveDocument.Sentences.count
   
    For i = 1 To nrOfSentences - 1
        s = ActiveDocument.Sentences(i)
       
        For j = i + 1 To nrOfSentences
            If s = ActiveDocument.Sentences(j) Then
                MsgBox s, vbOKOnly, "Duplicate sentence"
            End If
        Next
    Next i

End Sub

===================================

You probably want to change the MsgBox line with whatever own logic you have.

But honestly, I wouldn't try the above code myself. Considering the inaccurate definition of what a sentence is, results might be unpredicatiable. For example, according to Word "John F. Kennedy was shot." are actually 2 sentences. But probably more important, the above function will be extremely slow. I would be surprised if it takes several hours, maybe even days, to check a large document.

1 person found this reply helpful

Was this reply helpful?

Yes
No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated July 14, 2021 Views 17,895 Applies to: