Search code examples
c#.netms-wordspell-checking

Is there a way to interact with Word's spell & grammar check programmatically?


I'm looking for an efficient way to interact programmatically (outside of Word) with Word's spell and grammar check functionalities.

I found this 11-year-old article but I am sure there is a better way to achieve this today?

https://devblogs.microsoft.com/scripting/hey-scripting-guy-how-can-i-check-spelling-and-grammar-in-microsoft-office-word/

Yet I was unable to find anything recent on the topic - could someone point me toward a good way to get started with 2019 products?


Solution

  • If you add a COM reference to Microsoft Word 16.0 Object Library, then you can do something like:

    var app = new Microsoft.Office.Interop.Word.Application();    
    var spellingIsCorrect = app.CheckSpelling("hello");
    var grammarIsCorrect = app.CheckGrammar("is my grammar correct?");