Solved

Delete blank lines in a Document

Posted on 2006-06-09
8
2,825 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

A Knowledge Base That Stays Up-to-Date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Word 2010 MailMerge 4 37
MS Word - What are these fields?  New to 2010? 2007? 4 58
Renumber Word data 5 46
Mail Merge/EMail 10 53
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
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 …

758 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

18 Experts available now in Live!

Get 1:1 Help Now