How do I extract duplicate words in a doc?

  • Thread starter Thread starter tturner80126
  • Start date Start date
T

tturner80126

I am trying to identify duplicate words in a document and either extract or
highlight.
After researching this, I am at a loss. Is this possible, and if so, what
is the procedure?

Thx in advance for the help.
 
You can highlight (or delete) duplicated words using a macro something like
this:
Sub FlagDupWords()
Dim oCol As Collection
Dim oWord As Range
Set oCol = New Collection
For Each oWord In ActiveDocument.Words
On Error GoTo Err_Handler
oCol.Add LCase(Trim(oWord)), LCase(Trim(oWord))
Err_ReEntry:
On Error GoTo 0
Next
Exit Sub
Err_Handler:
If Err.Number = 457 Then
MsgBox oWord & " is a duplicated word and will be flagged."
If oWord.Characters.Last = " " Then oWord.MoveEnd wdCharacter, -1
oWord.HighlightColorIndex = wdBrightGreen
Resume Err_ReEntry
Else
MsgBox Err.Number & " " & Err.Description
End If
End Sub


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top