
Tips.Net > WordTips Home > Editing > 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
Great Idea! Word is a tool to get what you really want—printed output. This means you need to make sure that Word works as well as possible with your printer, whether it is sitting on your desk or in a room down the hall.
Check out WordTips: Printing and Printers today!
The real power behind Word's best documents lies in understanding styles and templates. Learn the key to more powerful document creation. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Word2007 Tips
WordTips