Using AutoCorrect on Existing Documents

Last reviewed: February 5, 1998
Article ID: Q153670
The information in this article applies to:
  • Microsoft Word for Windows versions 6.0, 6.0a, 6.0c,
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, versions 7.0, 7.0a

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.