Welcome toWord.Tips.Net
Ask a Word Question
Make a Comment
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
Collapsing and Expanding Subdocuments
One of the biggest problems in formatting what was previously an ASCII file is modifying it so there are only hard returns at the end of paragraphs. Most ASCII files have a hard return at the end of every line of the file, and two hard returns at the end of every paragraph. If you have an ASCII file that is formatted like this, such as something you downloaded off the Internet, the following macro will be invaluable. It formats an entire file so there are only hard returns at the end of paragraphs.
Sub ConvertASCII()
Fmt "^p^p", "{|}"
Fmt "^p", " {@}"
Fmt " {@}", " "
Fmt "{@}", " "
Fmt "{|}", "^p"
End Sub
Sub Fmt(sFromWord, sToWord)
Set myRange = ActiveDocument.Content
myRange.Find.ClearFormatting
myRange.Find.Execute FindText:=sFromWord, _
ReplaceWith:=sToWord, MatchCase:=0, _
Replace:=wdReplaceAll
End Sub
You should run the ConvertASCII macro. It calls the Fmt macro several times to replace various combinations of return characters to get toward the desired result.
Tip #187 applies to Microsoft Word versions: 97 2000 2002 2003 2007
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.