?
Solved

Delete blank lines in a Document

Posted on 2006-06-09
8
Medium Priority
?
2,868 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 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
Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses
Course of the Month8 days, 5 hours left to enroll

765 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