deleting empty lines

S

shark102

hello

I import a lot of data from database into WORD and it assumes the following
format: (I am trying to simulate formatting marks, hope it is clear)

text.text.number....................^p
.............=====....................^p
.............number....................^p
............................................^p
............................................^p
............................................^p
............................................^p
............................................^p
............................................^p
text.text.number....................^p
.............=====....................^p
.............number....................^p
............................................^p
............................................^p
text.text.number....................^p
.............=====....................^p
.............number....................^p
etc...

The thing I need to do is to delete blank lines, but only if there are 3 or
more blank lines in a row. (so that 2 empty lines always separate set of
data)
Any help appreciated.

Thanks in advance.
 
G

Graham Mayor

If I understand you correctly, a wildcard search for
^13{3,}
replace with
^p^p^p
should do the trick if the lines are truly blank- but the rows of
"................."
throw doubt on that. What do the dots represent, if anything?
If they are dots then
first run a wildcard replace of
..@^13
with
^p
If they are spaces change the dot to a space.

The following macro incorporates that and assumes a space for the dot.

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " @^13"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^13{3,}"
.Replacement.Text = "^p^p^p"
End With
Selection.Find.Execute replace:=wdReplaceAll

See http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

shark102

hello

dots represent spaces

macro works, I did not change anything there.

Thank you very much.
 

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