Word.Tips.Net Welcome toWord.Tips.Net

Helpful Links

Tips.Net Home
WordTips Home

Ask a Word Question
Make a Comment

Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

Newest Tips

Setting Fraction Bar Overhang Spacing in the Equation Editor

Printing On Both Sides of the Paper

Turning Off AutoComplete for Dates

Ordering Search and Replace

Understanding Auto Line Spacing

Adding Comments to Your Document

Conditional Calculations in Word

 

Formatting Text Files with WordBasic

Summary: A handy WordBasic macro that helps you format e-mail messages and other text files. (This tip works with Microsoft Word 6, and Word 95.)

It is not uncommon to need to format text files in Word. For instance, you may get an e-mail message from someone that needs formatting, or you may get an ASCII file from a friend. The most common necessities in formatting such a file is to remove extra spaces or tabs from the beginning of a line, extra spaces or tabs from the end of a line, removing "reply" characters from the beginning of each line, and combining lines to make paragraphs.

Doing all this by hand is very time-consuming work, and can easily drive you batty, particularly if the file is very large. The following macro, DoASCII, should make it easier for you. It accomplishes all the tasks just recounted, and does it very quickly. This version is designed to work with Word 6 or Word 95:

Sub MAIN
StartOfDocument
EditFindClearFormatting
EditReplaceClearFormatting
EditReplace .Find = "^p^w", .Replace = "^p", .Direction = 0, _
  .MatchCase = 0, .WholeWord = 0, .PatternMatch = 0, _
  .SoundsLike = 0, .ReplaceAll, .Format = 0, .FindAllWordForms = 0
EditReplace .Find = "^p> ", .ReplaceAll
EditReplace .Find = "^p> ", .ReplaceAll
EditReplace .Find = "^p> ", .ReplaceAll
EditReplace .Find = "^p> ", .ReplaceAll
EditReplace .Find = "^p^w", .ReplaceAll
EditReplace .Find = "^w^p", .ReplaceAll
EditReplace .Find = "^p^p", .Replace = "[{}]", .ReplaceAll
EditReplace .Find = "^p", .Replace = " ", .ReplaceAll
EditReplace .Find = "[{}]", .Replace = "^p", .ReplaceAll
End Sub

You should note that this macro will replace up to four levels of "> " characters put at the beginning of a line. It also assumes that the only place you want paragraph breaks are those places where a blank line exists.

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

More Power! For some people, the prospect of creating Word macros can be scary. WordTips: The Macros can help you conquer your fears and you'll discover you're much more confident and productive as you make Word do exactly what you want. This is an invaluable source for learning macros. You are introduced to the topic in bite-sized chunks, pulled from past issues of WordTips. Learn at your own pace, exactly the way you want.
 
Check out WordTips: The Macros today!