Solved

Delete blank lines in a Document

Posted on 2006-06-09
8
2,855 Views
Last Modified: 2008-03-19
I have a word document that is generated by a batch commnand that pings every machine in my domain and outputs to a Pinged.doc file.. After completion, I run a search and replace to get rid of unwanted lines to leave me with simply the machine name, percent loss and IP address. This leaves many blank lines throughout the document. I just need a VB script that will run through the document, line by line, and if the line is blank, delete it. I know that this is a simple fix, but I just can't get it. Any help would be appreciated.
0
Comment
Question by:sscottincanyon
  • 4
  • 3
8 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 125 total points
ID: 16871964
You dont need a script.

Just do Find and Replace on paragraph marks.
Find : ^p^p
Replace: ^p

Do this until you get no replacements reported.
0
 
LVL 2

Author Comment

by:sscottincanyon
ID: 16872437
Thanks for the help. It didn't quite work. When I use :
Find : ^p^p
Replace: ^p
I get zero results, however, if i use
Find : ^p
Replace:
it removes about half of the blank lines.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16872785
It may be that your document does not always use paragraphs to start new lines. That is the normal way, but yours could be different. For example, you could be using newline characters that are found by ^l ( carat and lower case L).

You could try posting a sample document here:
http://www.ee-stuff.com/
and informing us by posting another comment in this question.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:Galisteo8
ID: 16872835
Click the Show/Hide button on Word's toolbar to show non-printing characters (paragraph marks, manual line breaks, tabs, etc.)  That way, you can see what it is you need to be searching for.  Could be a combination of paragraph and manual line break, which is why searching/replacing for only one or the other removes only some of the lines.
0
 
LVL 2

Author Comment

by:sscottincanyon
ID: 16873408
Ok, GrahamSkan, I have uploaded the document to https://filedb.experts-exchange.com/incoming/ee-stuff/192-pingedtest.zip . Galisteo8, I will try what you have suggested.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16874099
It works as I suggested with your text document, except that (by the design of Word documents) it cannot replace the last paragraph mark, so it always reports one replacement.
0
 
LVL 2

Author Comment

by:sscottincanyon
ID: 16874219
GrahamSkan, I am going to have to take your word for it. I have fought this all day. I finally renamed my file and downloaded what I had uploaded for you and did exactly what you said, and it worked. Go figure, I have had weird things happening to my network all week. I really appreciate you help. This will save me a lot of time as I have to run this several times.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16874293
Thanks, not least for your trust and persistence. If you really needed a macro, I would have written one for you - see my answers - but 'the simpler the better' is one of my precepts.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question