Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 01-16-2011, 11:32 PM
macropod's Avatar
macropod macropod is offline keep only sentences beginning with: Wind Windows 7 32bit keep only sentences beginning with: Wind Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sentences and paragraphs keep disappearing in Word XP (2002) at bottom of page urobolus Word 3 08-26-2011 10:02 AM
Dash in the beginning of a new line Wakinyan Word 0 07-11-2010 07:10 AM
keep only sentences beginning with: Wind Add text to the beginning/ending of each line in word ballmoney Word 1 01-17-2010 02:19 AM
Looping macros to add text to beginning and end of a paragraph pachmarhi Word VBA 0 02-16-2009 06:57 AM
capitalize first letter of sentences norco1 Word 0 06-25-2006 12:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft