CheckGrammar Method

Applies To

Application object, Document object, Range object.

Description

Syntax 1: Begins a spelling and grammar check for the specified document or range. If the document or range contains errors, this method displays the Spelling and Grammar dialog box (Tools menu), with the Check grammar option selected. When applied to a document, this method checks all available stories (such as headers, footers, and text boxes).

Syntax 2: Checks a string for grammatical errors. Returns True if the string contains no errors.

Syntax 1

expression.CheckGrammar( )

Syntax 2

expression.CheckGrammar(String)

expression Syntax 1: Required. An expression that returns a Document or Range object.

Syntax 2: Required. An expression that returns an Application object.

String Required String. The string you want to check for grammatical errors.

See Also

CheckGrammarAsYouType property, CheckGrammarWithSpelling property, CheckSpelling method, GrammarChecked property.

Example

This example begins a spelling and grammar check for all stories in the active document.

ActiveDocument.CheckGrammar
This example begins a spelling and grammar check on section two in MyDocument.doc.

Set Range2 = Documents("MyDocument.doc").Sections(2).Range
Range2.CheckGrammar
This example begins a spelling and grammar check on the selection.

Selection.Range.CheckGrammar
This example displays the result of a grammar check on the selection.

pass = Application.CheckGrammar(String:=Selection.Text)
MsgBox "Selection is grammatically correct: " & pass