Join all lines at start of a word and end of a word

A

amberdevo

I have 5000 records which were saved as txt file from a webside. Who knows
why but with word2000 when I opened the file and removed line wrap all the
lines in a heading paragraph were joined together in one long string. This is
what I need to do so I can convert these records to MARC library cataloging
records. Now, with word 2003, removing line wrap does nothing. Most of the
document has the same format. I want to find for instance Title and select
all lines in that pararaph, then join all the lines on one continous line.
Example of format.

Title Joe Blow beat my fish then ran away with the cokies.
The police did nothing
Summary This video is a good example of how to beat a fish
and not get prosecuted
Copyright 1999

then the next record in the file

What I need to accomplish

Title Joe Blow beat my fish then ran away with the cokies.The police did
nothing
Summary This video is a good example of how to beat a fish and not get
prosecuted
Copyright 1999
 
G

Graham Mayor

Assuming all the records have exactly the same format then you can run four
wildcard replace routines to make the changes you require

^l(Title)
replace with
^p\1

^l(Summary)
replace with
^p\1

^l(Copyright)
replace with
^p\1

and

^l([!^l])
<space>\1

This assumes the line feed character is ^l
so first repace ^l3 with ^l to make it so

Thus

Sub FormatList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("^13", "^l(Title)", "^l(Summary)", "^l(Copyright)",
"^l([!^l])")
vReplText = Array("^l", "^p\1", "^p\1", "^p\1", " \1")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


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