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

Tips.Net > WordTips Home > Files > Formatting Text Files with WordBasic

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


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
Vital News Home

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.)