View Single Post
  #10   Report Post  
Posted to microsoft.public.word.docmanagement
SN SN is offline
external usenet poster
 
Posts: 2
Default How do I delete duplicate entries in a Word document?

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?