Document.GrammaticalErrors Property (2007 System)

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.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property GrammaticalErrors As ProofreadingErrors
'Usage
Dim instance As Document 
Dim value As ProofreadingErrors 

value = instance.GrammaticalErrors
[BrowsableAttribute(false)]
public ProofreadingErrors GrammaticalErrors { get; }
[BrowsableAttribute(false)]
public:
property ProofreadingErrors^ GrammaticalErrors {
    ProofreadingErrors^ get ();
}
public function get GrammaticalErrors () : ProofreadingErrors

Property Value

Type: ProofreadingErrors
A ProofreadingErrors collection that represents the sentences that failed the grammar check on the document.

Remarks

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).

Examples

The following code example adds ungrammatical text to the first paragraph and then checks whether there are any errors.

This example is for a document-level customization.

Private Sub DocumentGrammaticalErrors()
    Me.Paragraphs(1).Range.InsertParagraphAfter()
    Me.Paragraphs(1).Range.Text = "This is a ungrammatical sentence." 
    Me.CheckGrammar()
    System.Windows.Forms.Application.DoEvents()
    If Me.GrammaticalErrors.Count = 0 Then
        MessageBox.Show("There are no grammatical errors.")
    Else 
        Me.CheckGrammar()
    End If 
End Sub
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();
    }
}

.NET Framework Security

See Also

Reference

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace