Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-24-2012, 02:51 PM
Chayes Chayes is offline Selecting text between two key phrases Windows XP Selecting text between two key phrases Office 2003
Advanced Beginner
Selecting text between two key phrases
 
Join Date: May 2012
Posts: 79
Chayes is on a distinguished road
Default Selecting text between two key phrases

Hi



I'm using this code to select text between two key phrases ;

Code:
Dim myrng As Range, endrng As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
  Do While .Execute(findText:="MORE INFO ABOUT THE ITEM ", MatchCase:=True, Forward:=True, Wrap:=wdFindStop) = True
    Set myrng = Selection.Range
  Loop
End With
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
  Do While .Execute(findText:="ITEM NUM : ", MatchCase:=True, Forward:=True, Wrap:=wdFindStop) = True
    Set endrng = Selection.Range
  Loop
End With
myrng.End = endrng.End
myrng.Select
Unfortunately this only selects the first occurence and no others in the text. If there is more than one occurence the code selection spans whole tract of text.

I'd like it to select all of the specific occurences in the passage. If there are several times when the two inputs phrases can be found then it should find and select all occurences discretely.

Can someone advise with some modification or alternative code?

Grateful for any help.

Last edited by macropod; 06-24-2012 at 04:29 PM. Reason: Added code tags & formatting
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about selecting text w/mouse Jazz43 Word 3 11-29-2011 11:58 PM
Selecting styled text Caroline Word 5 02-15-2011 12:55 PM
Selecting text between two key phrases Automatically Hyperlink phrases TinaIgnatiev Word 1 12-22-2010 01:42 PM
Selecting text between two key phrases Selecting specific text out of a series of columns speedycorn1 Word 3 11-01-2010 02:58 PM
Selecting a Text Box gajesh Word 0 09-02-2009 11:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:47 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