View Single Post
  #14   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default How do I delete duplicate entries in a Word document?

If you don't know how to use Greg's code, see
http://www.gmayor.com/installing_macro.htm
If the e-mail addresses are simply in a list where each address is on one
line, then sort the list into alphabetical order and use Replace to remove
the duplicates - see the examples at
http://www.gmayor.com/replace_using_wildcards.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


SN wrote:
Dear Greg,
Thanks vm .... but this appears too technical to me.... I am just an
average computer user and cannot really understand what you say.....
Isnt there any straightforward way to 'DELETE DUPLICATE WORDS IN A
DOCUMENT?"
Rgds/SN

"Greg Maxey" wrote:

Provided the email entries are of the ????????@??????.??? format
(where ? is any character) then this might work:

Sub ScratchMacro()
Dim pStr As String
Dim oRng As Range
Dim i As Long
Dim j As Long
Dim oFld As Field
Dim bLoop As Boolean
i = 1
bLoop = True
Do
Set oRng = ActiveDocument.Range
oRng.Start = i
With oRng.Find
.Text = "?{1,}\@?{1,}.?{3}"
.MatchWildcards = True
Do
.Execute
If Not .Found Then
bLoop = False
Exit Do
End If
If oRng.Start = i Then
pStr = Trim(oRng.Text)
i = oRng.End
j = 0
For Each oFld In ActiveDocument.Fields
If InStr(oFld.Code, pStr) 0 Then
j = j + 1
If j 1 Then
oFld.Delete
End If
End If
Next oFld
Exit Do
Else
oRng.Collapse wdCollapseEnd
End If
Loop While .Found = True
End With
Loop While bLoop = True
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


SN wrote:
Helo, I am facing exactly the same problem. Did you find the
answer?? I will very much appreciate if you can share it with me.
Thank you very much
SN

"ayesha" wrote:

I have a large word document with lots of email addresses, many of
which are duplicate entries- how do I delete these repeat entries
without having to rely on the ControlF function?