Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

deleting empty lines

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shark102 - 11 Jan 2006 13:52 GMT
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.
Graham Mayor - 11 Jan 2006 14:16 GMT
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

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> hello
>
[quoted text clipped - 27 lines]
>
> Thanks in advance.
shark102 - 11 Jan 2006 15:15 GMT
hello

dots represent spaces

macro works, I did not change anything there.

Thank you very much.

> If I understand you correctly, a wildcard search for
> ^13{3,}
[quoted text clipped - 69 lines]
> >
> > Thanks in advance.
Greg - 11 Jan 2006 15:35 GMT
See:
http://gregmaxey.mvps.org/Clean_Up_Text.htm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.