Grammar Changes within Macro

R

Reitanos

Hi,

I'm doing a change case (Title) with a selection in a macro and would
like to let Word make any grammar suggestions within the selected
text. Is there a command that will allow this?
Also, is there a way to count how many suggestions there are within
the selection?

Thanks in advance for your assistance.
 
S

StevenM

To: Reitanos,

'
' If Spelling & Grammar dialog box pops up,
' press cancel
'
Sub TestGrammar()
Dim newDoc As Document
Dim oRange As Range
Dim gramErr As Variant

Set newDoc = Documents.Add
Set oRange = newDoc.Range
oRange.Text = "Once upon a time, there was a boy. Boy throw apples
oranges fruit. And then he ran away."
If newDoc.GrammarChecked = False Then
newDoc.CheckGrammar
End If

Set gramErr = oRange.GrammaticalErrors
MsgBox "Number of Errors: " & gramErr.Count
Set oRange = oRange.GrammaticalErrors(1)
MsgBox "Error: " & oRange.Text

End Sub

Steven Craig Miller
 
R

Reitanos

Thanks!

To: Reitanos,

'
' If Spelling & Grammar dialog box pops up,
' press cancel
'
Sub TestGrammar()
Dim newDoc As Document
Dim oRange As Range
Dim gramErr As Variant

Set newDoc = Documents.Add
Set oRange = newDoc.Range
oRange.Text = "Once upon a time, there was a boy. Boy throw apples
oranges fruit. And then he ran away."
If newDoc.GrammarChecked = False Then
newDoc.CheckGrammar
End If

Set gramErr = oRange.GrammaticalErrors
MsgBox "Number of Errors: " & gramErr.Count
Set oRange = oRange.GrammaticalErrors(1)
MsgBox "Error: " & oRange.Text

End Sub

Steven Craig Miller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top