delete blank lines

J

Jeff

Can someone post code that will delete all blank lines in a Word document?

Is code necessary for this or is there another way to do it? THANKS!

Jeff
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Jeff,

Just how you go about this depends on how those blank lines were created.
If you click on the Show/Hide ¶ button, what do you see?

If each blank line contains only a ¶

such as this¶

some more text, then you can use Edit Replace to search for ^p^p and replace
it with ^p. If you have something like

some text¶



some more text, you can use a wild card Edit Replace where you place

^13{2,}

in the Find what box and

^p

in the replace with box.

See the article “Finding and replacing characters using wildcards” at:

http://www.mvps.org/word/FAQs/General/UsingWildcards.htm

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
J

Jonathan West

Hi Jeff,

If by blank lines, you mean empty paragraphs, you don't need a macro. Open
the Edit Replace dialog. In the "Find What" box, type ^p^p. In the Replace
With box, type ^p. Click Replace All. Carry on clicking Replace All until
Word reports that no replacements have been made.
 
J

Jeff

Excellent! Thanks!

What I have is a text file of delimited fields that I import into an access
table. The text file has many blank lines that must be taken out before I
can import the data into a table. The number of blank lines varies from 1
to 13 in various places. Your wildcard solution works! I didn't know Word
accepted wildcards in the find box.

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
 

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