Expand Minimize

DocumentBase.GrammaticalErrors Property

Gets a ProofreadingErrors collection that represents the sentences that failed the grammar check on the document.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public ProofreadingErrors GrammaticalErrors { get; }

Property Value

Type: Microsoft.Office.Interop.Word.ProofreadingErrors
A ProofreadingErrors collection that represents the sentences that failed the grammar check on the document.

There can be more than one error per sentence.

If there are no grammatical errors, the Count property for the ProofreadingErrors object returned by the GrammaticalErrors property returns 0 (zero).

The following code example adds ungrammatical text to the first paragraph and then checks whether there are any errors. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentGrammaticalErrors()
{
    this.Paragraphs[1].Range.InsertParagraphAfter();
    this.Paragraphs[1].Range.Text = "This is a ungrammatical sentence.";
    this.CheckGrammar();
    System.Windows.Forms.Application.DoEvents();
    if (this.GrammaticalErrors.Count == 0 )
    {
        MessageBox.Show("There are no grammatical errors.");
    }
    else
    {
        this.CheckGrammar();
    }
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft