Extracting certain lines

  • Thread starter Thread starter Susan
  • Start date Start date
S

Susan

I have MS Office 2003. What is the best way to copy text into application
and then extract only the lines containing certain word? Can I do that with
MS Word?

Is there also a way to replace text in line with blanks after certain
delimeter?

Thanks for information.
Susan
 
Yes, the first can be done with some vba code that searches for the word and
then sets a Range variable to the .Range of the Selection.Bookmarks("\line")
range.

This will give you an idea of the syntax

' Macro to round all numbers in a document

' Macro created 19/7/00 by Doug Robbins

'

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,}.[0-9]{3,}", MatchWildcards: =
True, Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Text = Round(Selection.Range.Text, 2)
Loop
End With

The second you can do with a wildcard Replace.

See the article "Finding and replacing characters using wildcards" at:

http://word.mvps.org/FAQs/General/UsingWildcards.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
Back
Top