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

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
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

Newest Tips

Underlining Quoted Text

Changing Tabs Using the Ruler

Moving Drawing Objects

Standardizing Note Reference Placement

Selecting Printing of Color Pictures

Stubborn Foreign Languages

Sizing the Preview Pane

 

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

Step Up and Take Control! Subscribers to WordTips know just how valuable a resource it is. WordTips Premium provides twice the number of exceptional, easy-to-understand tips every week in an ad-free newsletter, as well as substantial discounts on WordTips archives and e-books.
 
Check out WordTips Premium today!