Share via


CheckGrammar Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

CheckGrammar method as it applies to the Application object.

Checks a string for grammatical errors. Returns a Boolean to indicate whether the string contains grammatical errors. True if the string contains no errors.

expression.CheckGrammar(String)

expression   Required. An expression that returns an Application object.

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

CheckGrammar method as it applies to the Document and Range objects.

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 check box selected. When applied to a document, this method checks all available stories (such as headers, footers, and text boxes).

expression.CheckGrammar

expression   Required. An expression that returns a Document or Range object.

Example

As it applies to the Document object.

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

  ActiveDocument.CheckGrammar

As it applies to the Range object.

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

As it applies to the Application object.

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

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