What i'm looking for, is a macro which finds every occurrence of
certain string, and delete the text which follows it (in the same line)
for instance, given this text:
bla bla bla //this should be removed
bla bla bla //this should be removed
bla bla bla //this should be removed
After executing the macro, I'd want to have
bla bla bla
bla bla bla
bla bla bla
I tried with the following code, expecting that it would find "//"
every time this string is in the text, but it actually doesn't do the
job
With ActiveDocument.Content.Find
.ClearFormatting
.Style = wdStyleHeading3
.Text = "//"
Do While .Execute(Forward:=True, Format:=True) = True
MsgBox "se encontró //"
Loop
End With
I'm really new in VBA, so any tips would be apreciated
tnx - jm
Greg - 22 Feb 2006 18:40 GMT
If you line ends with a paragraph mark, you could use:
Sub Test()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Text = "//"
While .Execute
oRng.MoveEndUntil vbCr
oRng.Delete
Wend
End With
End Sub
julian_m - 22 Feb 2006 18:48 GMT
> If you line ends with a paragraph mark, you could use:
>
[quoted text clipped - 10 lines]
> End With
> End Sub
It works like a charm ;) Tnx
regards - jm