PC Review


Reply
Thread Tools Rate Thread

How do I extract duplicate words in a doc?

 
 
tturner80126
Guest
Posts: n/a
 
      24th Feb 2008
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.
 
Reply With Quote
 
 
 
 
Greg Maxey
Guest
Posts: n/a
 
      24th Feb 2008
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
Word MVP web site http://word.mvps.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~


"tturner80126" <(E-Mail Removed)> wrote in message
news:CC551AB2-187F-49C1-91A8-(E-Mail Removed)...
>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.



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to extract words out from a string? =?Utf-8?B?U2xpbmc=?= Microsoft C# .NET 7 13th Dec 2005 10:02 PM
Extract words from a string Maya Microsoft C# .NET 3 31st Mar 2005 12:25 AM
Extract last words in cell Shaz Microsoft Excel Misc 3 24th Oct 2004 08:10 AM
Extract first words from each paragraph Roger Smith Microsoft Word Document Management 2 2nd Sep 2004 01:49 PM
How to extract all words in a cell except the last one? bianling Microsoft Excel Misc 6 26th Feb 2004 05:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:04 AM.