bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Editing > Stripping Trailing Spaces with WordBasic

Stripping Trailing Spaces with WordBasic

Summary: A quick way to remove trailing spaces from a paragraph. (This tip works with Microsoft Word 6, and Word 95.)

Maybe I'm one of those compulsive-obsessive types, but I always go through my documents to make sure there are no trailing spaces at the end of a line. This makes the document neater and smaller. If you format ASCII files, you will need to search for trailing spaces, and remove them, as you format the file for Word. The following WordBasic macro, StripSpaces, will take out all spaces before paragraph marks and manual line breaks throughout your document.

Sub MAIN
StartOfDocument
EditFindClearFormatting
EditReplaceClearFormatting

EditFind .Find = " ^p", .WholeWord = 0, .MatchCase = 0, \
.Direction = 1, .Format = 0
While EditFindFound()
    StartOfDocument
    EditReplace .Find = " ^p", .Replace = "^p", \
    .WholeWord = 0, .MatchCase = 0, .Format = 0, \
    .ReplaceAll = 1
    RepeatFind
Wend

EditFind .Find = " ^l", .WholeWord = 0, .MatchCase = 0, \
.Direction = 1, .Format = 0
While EditFindFound()
    StartOfDocument
    EditReplace .Find = " ^l", .Replace = "^l", \
    .WholeWord = 0, .MatchCase = 0, .Format = 0, \
    .ReplaceAll = 1
    RepeatFind
Wend

End Sub

Tip #968 applies to Microsoft Word versions: 6 | 95


Take Control! Master the real power behind Word! Successfully master the secrets of powerful formatting and create documents that stand out from the rest. Best of all, you can create documents that are easy to maintain and quick to change.
 
Check out Word 2007 Styles and Templates today!

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)