Solved

Delete blank lines in a Document

Posted on 2006-06-09
8
2,836 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

864 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now