How to find some text in the end of every paragraphs and move it into the start those paragraphs?

A

avkokin

Hello.
I can't understand (I have a bad logic) how to find some text in the
end of every paragraphs and move it in to the start those paragraphs?
For example, there is some text:
1 text some Str.
text some
text some
....
4 text some Str.
5 text some Str.

I need to get:
Str. 1 text some
text some
text some
....
Str. 4 text some
Str. 5 text some

Every line is a paragraph (with pilcron).

I will very grateful if somebody explain for me all algorithm of such
search.
Regards, Anton
 
H

Helmut Weber

Hi Anton,

the question is, what is "Str."?

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
A

avkokin

Hello Helmut.

"Str." it is the word (abbreviation for "Sreet"). It should stand as
first word - it should move to start position.

Thank you.
 
H

Helmut Weber

Hi Anton,

there is no straightforward method to move text,
only copying, deleting and pasting or
deleting and inserting, like:

Sub Test456bb()
Dim i As Long
Dim oPrg As Paragraph
For Each oPrg In ActiveDocument.Paragraphs
If Right(oPrg.Range.Text, 5) = "Str." & Chr(13) Then
For i = 1 To 4
oPrg.Range.Characters.Last.Previous.Delete
Next
oPrg.Range.InsertBefore "Str."
End If
Next
End Sub

There are lots of other ways...

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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