Find "Out of" then a comma then Delete

S

Steved

Hello from Steved

Find "Out of" turn on "extend" then highlite to the next "comma" then Delete
I was hoping my atempt would work but it will not
What do I need to do please

Sub Part5()
ActiveDocument.Range.Find.Execute _
FindText:="(* Out of *) Out of *,", _
ReplaceWith:="\1,", _
MatchWildcards:=True, _
Replace:=wdReplaceAll
End Sub
Thankyou
 
D

Doug Robbins - Word MVP

Use:

Dim drange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="Out of", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=True) = True
Set drange = Selection.Range
drange.End = ActiveDocument.Range.End
drange.End = drange.Start + InStr(drange, ",")
drange.Delete
Loop
End With


--
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
 

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