Written by Allen Wyatt (last updated July 11, 2020)
This tip applies to Word 97, 2000, 2002, and 2003
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.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (187) applies to Microsoft Word 97, 2000, 2002, and 2003.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Tired of the formatting used in a paragraph? One way to "start over" is to make sure that the formatting is reset to its ...
Discover MoreWhen you get one paragraph formatted just the way you want, you might want to copy that formatting so it can be applied ...
Discover MoreNeed a quick shortcut that you can use to center your paragraph between the margins? The answer is here.
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-12-04 15:06:32
Bill Jeffrey
Re formatting an ASCII file - paragraph marks. Assuming you are doing this as a one-off, and not habitually, Word's FIND and REPLACE can do the same thing without the bother of creating a macro. Just FIND ^p^p and REPLACE it with a tilde, for example. Then FIND ^p and REPLACE it with a space. Then FIND the tilde and REPLACE it with ^p (or with ^p^p if you want a blank line between paragraphs). Add ^t in the REPLACE field if you want a tab at the beginning of the paragraph.
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments