find and replace

S

shodgkin

I trying to clean up a directory list before printing. I want to remove all
lines containing "<dir>".
I also want to remove all lines with "0 file(s)", and the three lines above.
All that would be left to print would be non-empty directory names and their
contents.

Thanks,

Steve
 
D

Doug Robbins - Word MVP

Use:

Dim drange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="<dir>", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) =
True
Selection.Bookmarks("\line").Range.Delete
Loop
End With
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="0 file(s)", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) =
True
Selection.MoveStart wdLine, -3
Selection.Delete
Loop
End With


--
Hope this helps

Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to avail yourself of my
services on a paid, professional basis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top