Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Automatically Formatting an ASCII File.
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. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Automatically Formatting an ASCII File.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
One of the most basic ways to align paragraphs is to set the alignment used for the text in the paragraph. Word provides ...
Discover MoreThose with a publishing, typographic, or design background may understand what leading is, but not how to adjust the ...
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 © 2024 Sharon Parq Associates, Inc.
Comments