Share via


DocumentBase.GrammaticalErrors 屬性

取得 ProofreadingErrors 集合,表示在文件中文法檢查有錯誤的句子。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public ReadOnly Property GrammaticalErrors As ProofreadingErrors
public ProofreadingErrors GrammaticalErrors { get; }

屬性值

型別:Microsoft.Office.Interop.Word.ProofreadingErrors
ProofreadingErrors 集合,表示在文件中文法檢查有錯誤的句子。

備註

每個句子中可能有一個以上的錯誤。

如果沒有文法上的錯誤,GrammaticalErrors 屬性所傳回 ProofreadingErrors 物件的 Count 屬性會傳回 0 (零)。

範例

下列程式碼範例會將不合乎文法的文字加入至第一個段落,然後檢查是否有任何錯誤。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

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 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間