Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

How to: Programmatically Check Spelling in Documents

 

To check the spelling in a document, use the M:Microsoft.Office.Interop.Word._Application.CheckSpelling(System.String,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@) method. This method returns a Boolean value that indicates whether the supplied parameter is spelled correctly.

Applies to: The information in this topic applies to document-level projects and VSTO add-in projects for Word. For more information, see Features Available by Office Application and Project Type.

To check spelling and display results in a message box

  1. Call the M:Microsoft.Office.Interop.Word._Application.CheckSpelling(System.String,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@) method and pass it a range of text to check for spelling errors. To use this code example, run it from the ThisDocument or ThisAddIn class in your project.

                string result = "Spelled incorrectly.";
    
                object startLocation = this.Content.Start;
                object endLocation = this.Content.End;
                bool spellCheck = this.Application.CheckSpelling(
                    this.Range(ref startLocation, ref endLocation).Text);
    
                if (spellCheck == true)
                {
                    result = "Spelled correctly.";
                }
    
                MessageBox.Show(result);
    

How to: Programmatically Define and Select Ranges in Documents
Optional Parameters in Office Solutions

Show: