This documentation is archived and is not being maintained.

Document.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 (in microsoft.office.tools.word.dll)

public virtual ProofreadingErrors GrammaticalErrors { get; }

Property Value

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.

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();
    }
}

Show: