Using AutoCorrect on Existing Documents

ID: Q153670

The information in this article applies to:

SUMMARY

The 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 INFORMATION

WARNING: 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 Sub

NOTE: 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 KBSubcategory: Additional query words: 6.0 6.0a 6.0c 7.0 7.0a macword winword ntword word95 word7 wordbasic coding coded replacement exchange updating updates

Keywords          : kbmacro
Version           : 6.0 6.0a 6.0c 7.0 7.0a
Platform          : WINDOWS

Last Reviewed: January 20, 1999