Thread: [Solved] Word VBA - Find
View Single Post
 
Old 08-15-2012, 10:58 AM
telkomek telkomek is offline Windows XP Office 2003
Novice
 
Join Date: Aug 2012
Posts: 1
telkomek is on a distinguished road
Default when i'm test is looping forever

Quote:
Originally Posted by macropod View Post
Hi Sdoneti,

Try something like the following, which shows how you can get the next word, or even the whole paragraph:
Code:
Sub Demo()
With Selection.Range
  With .Find
    .ClearFormatting
    .Text = "Heading"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  Do While .Find.Found
    ' get the next word
    MsgBox .Words.Last.Next.Words.First
    ' get the whole paragraph
    MsgBox .Paragraphs.Last.Range.Text
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
End Sub
when i'm test is looping forever.
are only happen to me?
Reply With Quote