Spelling in Excel

Spelling in Excel


Excel provides spelling checker which provides best suggestions to fix grammatical mistakes in cells. Spelling checker works based on a predefined dictionary engine which performs close match between cell text and dictionary database to provide best suggestions. In this article we will see how we can enable Spelling check in a Sheet and automate the same.

  • Navigate Review ribbon tab
  • Click on Spelling button under Proofing group

For example I made a common mistake in my text and looks as below before fix:

figure 1.0

When user hits Spelling button a suggestion dialog comes by suggesting best possible relative matches to a word. User can perform various actions based on selection as:

  • Ignore Once: user can ignore current occurrence of the word
  • Ignore All: all occurrence of same word would be ignored
  • Add to Dictionary: user can add own word into dictionary database so next time word would not be considered as misspell
  • Change: replaces selected suggestion in the cell once
  • Change All: replaces selected suggestion for all occurrences
  • AutoCorrect: will replace match automatic

Post perform spell check the output would look like as:

figure 1.1

Let’s put some code to automate the process. We are using VSTO (Visual Studio Tools for Office) in both c# and VB style code hence following prerequisites are recommended to get working code:

  • Visual Studio 2015 or above having Microsoft Office for Developer Tool installed
  • Create Excel Addin in C# or VB code style (Visual Studio Tools for Office)
  • Excel 2010 or above
  • Create a ribbon designer and put button

C# code example:

private void btnSpelling_Click(object sender, RibbonControlEventArgs e)
	//Worksheet reference
	excel.Worksheet oWorksheet = Globals.ThisAddIn.Application.ActiveSheet;

	//Check spellings

VB.Net code example:

Private Sub btnSpellingCheck_Click(sender As Object, e As RibbonControlEventArgs) Handles btnSpellingCheck.Click
	'Get worksheet reference
	Dim oWorksheet As excel.Worksheet

	'Enable spelling checker
End Sub

VBA code example:

Public Sub CheckSpelling()
    'Worksheet reference
    Dim oWorksheet As Worksheet
    Set oWorksheet = ActiveSheet
    'Check spelling
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *