selections

M

MarcoPolo

i have a text like this
"1. .........................incoming __% ....................1980."

if i have condition "a" i need to put the percent and then delet till end of
paragraph
if i have condition "b2 i need to delte from beginning of sentence till
"incoming"

i selct the word incoming woth find method and i do selection type and so so
on...
But how can i delete from beginning of a paragraph till the location i am?
And how can i delete from location selected till end of pargraph?
 
H

Helmut Weber

H,

as this is a programmer's group, I assume,
that you can adapt the following:

Sub Test400()
Dim rTmp As Range
Dim bA As Boolean ' a condition
Dim bB As Boolean ' another condition
Set rTmp = Selection.Paragraphs(1).Range
' process the paragraph the start of the selection is in
bA = False ' as you like
bB = True ' as you like
If bA Then
With rTmp.Find
.Text = "_{1,}"
.MatchWildcards = True
.Replacement.Text = "16"
If .Execute(Replace:=wdReplaceOne) Then
While rTmp.Characters.Last.Next.Next <> chr(13)
rTmp.Characters.Last.Next.Next = ""
Wend
End If
End With
End If
If bB Then
With rTmp.Find
.Text = "incoming"
.MatchWildcards = False
If .Execute Then
rTmp.Start = Selection.Paragraphs(1).Range.Start
rTmp.End = rTmp.End - 8
rTmp.Select ' for testing
rTmp = ""
End If
End With
End If
End Sub

I'm not using "delete" as this may trigger autocorrect activities.
BTW, a single condition would probably be all you need.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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