you create a loop from after the execute statement using the
Selection.Find.Found property to test if the find has succeded.
The following should work, but I advise stepping through to ensure it
works as I have not tested it.
Cheers
TonyS.
Sub RemoveBeginningOfLine()
Selection.Find.ClearFormatting
With Selection.Find
.Text = ". PAC"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Do While Selection.Find.Found
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=3
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.Execute
Loop
End Sub
> One more thing I am having problems with - I need to find some specific text
> - space, period, space, space, PAC. This is the only common item to all the
[quoted text clipped - 28 lines]
> End Sub
> How do I make it continue?
Tailings - 05 Oct 2006 01:03 GMT
Worked like a charm! I had found a workaround, but your solution is FAR more
elegant! Thanks SO much!
> you create a loop from after the execute statement using the
> Selection.Find.Found property to test if the find has succeded.
[quoted text clipped - 64 lines]
> > End Sub
> > How do I make it continue?
Hi,
so, if a paragraph starts with " . PAC"
you want to remove " . " from that paragraphs start?
Note, that you talk about
>- space, period, space, space, PAC
while searching for period, space, space, PAC!
The information, that the search string is always
at the same position isn't very helpful,
as one would have to find out the position first.
It could help to speed up the macro, in theory,
as then no searching would be necessary at all.
Also:
>This is the only common item to all the
>lines that need to be changed,
tells, that all lines to be processed, contain " . PAC",
not that all lines containing " . PAC"
have to be processed. ;-)
However, I don't think you need more than this,
which does not check whether " . PAC" is at the
paragraph's start.
With ActiveDocument.Range.Find
.Text = " . PAC" ' leading space!
.Replacement.Text = "PAC"
.Execute Replace:=wdReplaceAll
End With
Still a bit a stab in the dark.
You may use the selection object, too,
search for "^p . PAC", and replace it with "^pPAC".
But as this would't work for the first paragraph,
I don't like it.
HTH

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Tailings - 05 Oct 2006 02:31 GMT
Sorry I wasn't very clear - or precise! I have been battling with this
project for several days and even dreamed I had the solution. How annoying to
wake up and find it still didn't work.
I am cutting and pasting text from a very primitive database and putting it
in what is supposed to be a relatively sophisticated-looking report. Right
now we go through and delete all the unneeded info manually, which take a
very long time. The macro work is speeding it up.
Thanks to all for the help!
> Hi,
>
[quoted text clipped - 38 lines]
>
> HTH