View Single Post
 
Old 01-16-2011, 11:32 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Michael,

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim RngSnt As Range, RngTmp As Range, strWrd As String
Dim i As Integer, bWrd As Boolean, ArrWrds As String
ArrWrds = "Wind,Winds,Donaway,Sagway"
With ActiveDocument
  For Each RngSnt In .Sentences
    bWrd = False
    With RngSnt
      strWrd = Trim(.Words.First.Text)
      For i = 0 To UBound(Split(ArrWrds, ","))
        If Split(ArrWrds, ",")(i) = strWrd Then bWrd = True: Exit For
      Next
      If bWrd = False Then
        Set RngTmp = RngSnt
        RngTmp.End = RngTmp.End - 1
        RngTmp.Delete
      End If
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 01-16-2011 at 11:36 PM. Reason: More efficient code
Reply With Quote