Using AutoCorrect on Existing DocumentsLast reviewed: February 5, 1998Article ID: Q153670 |
The information in this article applies to:
SUMMARYThe AutoCorrect option works dynamically when a space is entered following a word that appears in the AutoCorrect list. This feature operates while the document is being created, but Word does not automatically scan a previously-created document and make AutoCorrect changes. This article provides a sample macro that compares each word in a Word document to words in the AutoCorrect list and then replaces the matched words with the text string specified in the AutoCorrect list.
MORE INFORMATIONWARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. Create the following macro to search your documents, identify words that appear in both the document and the AutoCorrect list, and then insert the corresponding AutoCorrect text.
Sub MAIN StartOfDocument EditFindClearFormatting EditFind .Find = " ", .Direction = 0, .MatchCase = 0, .WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format = 0, .Wrap = 0, .FindAllWordForms = 0 While EditFindFound() WordLeft 1, 1 If GetAutoCorrect$(Selection$()) <> "" Then Insert GetAutoCorrect$(Selection$()) End If CharRight 2 EditFind Wend End SubNOTE: If you are working on a very long document, this macro may take a long time to run. To stop the macro before it is finished, press the ESC key. All changes made up to that point will be retained.
|
KBCategory: kbusage kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |