Microsoft KB Archive/142144

= Sample Macro to Edit AutoCorrect List =

Article ID: 142144

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 95 Standard Edition

-



This article was previously published under Q142144





SUMMARY
The following examples contain Visual Basic for Applications macros that you can use to add items to and remove items from the Microsoft Excel AutoCorrect list.

With AutoCorrect, changes are made to existing text only when a cell is activated. In addition, the AutoCorrect feature is case sensitive. That is, if you type the original word in capital letters, the replacement will be entered in capital letters as well.



MORE INFORMATION
Microsoft provides examples of Visual Basic for applications procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

To add an item to the AutoCorrect list
  In a new module sheet, enter the following code: Sub Add_Item

'The following macro code assigns "Msft" to replace any new 'occurrence of the word "Microsoft". Application.AutoCorrect.AddReplacement "Microsoft", "msft"

End Sub  Switch to a worksheet, and click Macro on the Tools menu. Run the Add_Item macro. To verify that the item was added to the list, click AutoCorrect on the Tools menu and scroll to the bottom of the window. To test the AutoCorrect entry, type Microsoft in any cell on your worksheet, and press ENTER.

The word "Microsoft" in the cell should automatically be changed to "Msft."

To remove an item from the AutoCorrect list
  In a module sheet, enter the following code: Sub Remove_Item

'The following macro code removes the replacement 'item for "Microsoft". Application.AutoCorrect.DeleteReplacement "Microsoft"

End Sub </li> Click Macro on the Tools menu, and run the Remove_Item macro.</li> To verify that the item was removed from the list, click AutoCorrect on the Tools menu, and scroll to the bottom of the window.</li></ol>

<div class="references_section">