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
Setting Fraction Bar Overhang Spacing in the Equation Editor
Printing On Both Sides of the Paper
Turning Off AutoComplete for Dates
Understanding Auto Line Spacing
Adding Comments to Your Document
Conditional Calculations in Word
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
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.