Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2011, 03:38 PM
macropod's Avatar
macropod macropod is offline Word VBA - Find Windows 7 32bit Word VBA - Find 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 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

__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 04-19-2011, 08:36 AM
SDondeti SDondeti is offline Word VBA - Find Windows XP Word VBA - Find Office 2007
Novice
Word VBA - Find
 
Join Date: Apr 2011
Posts: 7
SDondeti is on a distinguished road
Default

Hi Macropad,

Thank you. I used InsertCation to solve my problem.

CaptionLabels.Add Name:="Picture"
Selection.InsertCaption Label:="Picture", _
Title:=": ", _
Position:=wdCaptionPositionBelow, _
ExcludeLabel:=0

Thanks,
Sudhakar
Reply With Quote
  #3  
Old 08-15-2012, 10:58 AM
telkomek telkomek is offline Word VBA - Find Windows XP Word VBA - Find 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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA - Find Lost Word Document and cant find it!!! I saved it but it ISNT there!! APAV Word 9 10-09-2017 01:17 PM
How to find out the version of the word files? mariaprabudass Word 0 06-18-2010 05:40 AM
Word VBA - Find can Find/Replace NOT find something? Bobosmite Word 6 05-27-2010 08:09 PM
How to find the version of word file? mariaprabudass Word 6 04-29-2010 03:33 AM
FInd recurring words in Word 2003 NJ007 Word 4 01-25-2010 03:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:23 PM.


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